I'm doing some high density hosting of ASP.NET MVC 5 / WCF apps on Azure App Service and the idle apps are using 600~1000MB of memory each which is quite a lot, given that a memory dump reveals that the GC heap is only about ~40MB full. I suspect this is due to server GC so i tried disabling it by following https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcserver-element and adding
<gcServer enabled="false" />
to my web.config, but this does not appear to have any effect as
GCSettings.IsServerGC
is still returning true. What am i missing here?
EDIT:
Using normal IIS it can be done using https://weblogs.asp.net/owscott/setting-an-aspnet-config-file-per-application-pool but in Azure App Service, you lack the permissions to do this.
Ok, first of all, it seems like you might have to manually debug the memory usage of components using GC.Collect(): https://docs.microsoft.com/en-us/dotnet/api/system.gc.collect?view=netcore-3.1
This way you might be able to pinpoint a specific part of the code that either causes a memory leak due to bad garbage collection, or parts that are using certain third-party libraries.
Once you are done with this quite tedious part, then depending on what you think is causing the problem, you should consider either using a manual disposal of the code block utilizing (using var item = new NameOfClass())
or even trying ti implement IDispose
on the classes that are causing it: https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With