Pinning down the exact memory usage
I would like some guidance in tracking down specific memory use displayed by dotMemory, as shown below. It's already been very useful, showing that 50% of the memory is stored in HttpApplicationState, which is bad, and we will need to refactor that information to be stored in user session data instead of global application state.
Can you help me if we are interpreting the data in this screen properly. Are the following statements correct?
1) The application is using 2.41GB of memory
2) If this, 1.2GB (half) is in HttpApplicationState
3) Most of this 1.2GB is in a single variable called "InCache" (I have edited the name a bit)
4) This variable is an associative array with 431 elements. The element in array position [4] alone is taking about 201MB. We found 6 such large elements, which total equal almost 1.2GB.
5) So we should focus on finding why 6 out of 431 are taking almost all the space?
It would be helpful just to confirm our understanding of the above.
If all that is correct, then the question becomes more complicated. These cached elements are entity framework objects corresponding to some join of database records. These are not large data records, maybe a few hundred KB total when joined. No blob-type subfields are involved, just scalar database columns. So something is wrong about one object taking 200MB.
To get an idea of where the memory is used, I kept drilling down into the [4] object, but it just drills down circularly forever: I can keep drilling down the path shown in the second screenshot and keep getting that same large retained bytes of 201,053,454. The second screenshot shows how that large value keeps showing up however far you drill down.
This object is automatically constructed by the Entity Framework 6 library so we don't have direct control or knowledge of it. Any insights would be greatly appreciated, of how we can pin down the memory use (unless I'm misinterpreting something, of course). Thank you!
Screenshot #1:
Screenshot #2:
Please sign in to leave a comment.
DataAccess.Caching.Cache doesn't take 200 MB of memory, it takes only 32 bytes, but retains other objects and their total size it 200MB.
Please double click on the one of these nodes which retains 200MB (DataAccess.Caching.Cache) to open the object as a separate instance and click "Show retained objects by this instance" for DataAccess.Caching.Cache instance. You'll get object set with objects retained by it, for example, like here:
Thank you very much, using that "tree" icon on the left side I was able to drill down differently and get to a place where a lot of memory was being used, unexpectedly. Your answer was very helpful.