I have a question regarding the use of high memory as a web role with an MVC application, with Simple Injector like DI, Entity Framework 6 for DAL. The application runs on the Azure Cloud Service as a web role with 2 standard A2 instances (2 cores, 3.5 GB of RAM), and CachingService (Shared Role) with 20% memory usage.
The problem is that when you start or restart the instance, using the w3wp.exe memory using only about 500-600 MB of memory (when using all other applications, about 50%), but even if there are no requests in it, it starts and continues to grow to 1 , 7 GB and ends (when using all other applications about 90%). But I noticed that the memory sometimes crashes accidentally and, of course, after a reboot or republishing.
After monitoring the heap of memory, I noticed that this is a Gen2 Heap that grows and remains large, and after debugging locally with the ANTI Memory Profiler, I saw that the largest number of Gen2 was taken by Entity Framework objects with the class names “TypeUsage” and “MetadataProperty”, objects (namespace System.Data.Entity.Core.Metadata.Edm).
Now my question is:
- This is a memory leak in our code and how can I solve it if it is (I checked and already tried to remove the DbContext that each request is created)?
- Is it a memory leak in EF, if so, what can I do with it, maybe another DAL structure?
- Is this normal behavior and should I leave it as it is?
source share