Search code examples
memorygarbage-collectionclrheap-memorywindbg

How are CLR GC heaps mapped to native heaps?


For example, if I see that some of those heaps are pretty big, my next question would be who (native or managed code) uses them. How can I figure out which native heaps (!heap -s) CLR uses for its purpose?


Solution

  • The CLR uses VirtualAlloc to allocate memory segments to be used as the managed heaps. You can inspect the segments using !sos.eeheap -gc. !sos.dumpheap -stat will show you how much memory the managed heaps are using, and what types of objects are consuming memory.