Difference between CLR Heap Memory and Retained Size

Questions about YourKit .NET Profiler
Post Reply
[email protected]
Posts: 3
Joined: Tue Mar 28, 2017 12:41 pm

Difference between CLR Heap Memory and Retained Size

Post by [email protected] »

I am seeing a large difference between the Objects by Generation View retained size (260 MB) and the CLR Heap Memory (Used 508 MB, Allocated 522 MB). How can these numbers be so different? Why don't I see where the extra memory is being used? I am trying to figure out a memory leak we have and the snapshot difference shows a difference of only 3.6 MB whereas the CLR Heap Memory difference is 172 MB. Thanks for your help.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Difference between CLR Heap Memory and Retained Size

Post by Anton Katilin »

CLR Heap Memory graph shows total memory allocation for heap storage as reported by CLR. This includes heap storage overhead: gaps between objects, control structures etc.

The object views show a sum of all object individual sizes. I think we should attribute this difference to the above mentioned overhead.

Anyway, both the total sizes shown in the graph and the sum of object sizes shown in tables are exactly the values reported by the CLR. The profiler doesn't calculate them, just shows.
[email protected]
Posts: 3
Joined: Tue Mar 28, 2017 12:41 pm

Re: Difference between CLR Heap Memory and Retained Size

Post by [email protected] »

I am thinking maybe I have a Gen 2 heap fragmentation issue because of pinned objects on the managed heap. Is there any way I can use YourKit to help me figure that out? If you want I can send you my memory snapshots or screenshots of what I am seeing in the tool now.

Thanks

Richard
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Difference between CLR Heap Memory and Retained Size

Post by Anton Katilin »

Hello Richard

Unfortunately, you cannot see the fragmentation explicitly in the profiler. Pinned objects can be seen via "Memory |GC Roots".
If you want I can send you my memory snapshots or screenshots of what I am seeing in the tool now.
Yes, please. If you cannot share them in the forum please send them (or a download link) to [email protected]

Best regards,
Anton
Post Reply