Yanshof
Yanshof

Reputation: 9926

Architecture of the .net heap memory

when we talk about the windows memory architecture => we talking about the virtual memory manager that 'give' chunk of memory to the application manager heap that allocate the memory size that the application ask.

( http://msdn.microsoft.com/en-us/library/ms810466.aspx )

But in .net => is the .net managed heap is 'asking' memory from the virtual memory manager ( i'm almost sure this is the case ) or there is some layer between the .net managed heap and the virtual memory manager ?

( this question has no connection to GC )

Upvotes: 3

Views: 780

Answers (1)

Brian Rasmussen
Brian Rasmussen

Reputation: 116471

The .NET runtime basically acts as a memory manager for the managed heap. So every time you new an object it either advances the pointer on the gen0 GC heap (which may trigger a collection) or allocates a chuck on the Large Object Heap. The latter is similar to a regular CRT heap in that it uses a free list.

The GC heap itself is stored in segments which are allocated/freed to the OS as needed. This means that managed memory usage is usually not reflected immediately on the process level.

You can inspect how the managed heap is built from different segments through the SOS debugger extension which can be loaded in WinDbg (it can be loaded in VS as well, but the experience is a little rough if you ask me).

There are two books that come to mind: CLR via C# and Shared Source CLI. They both cover this to some extent.

Upvotes: 3

Related Questions