This post originated from an RSS feed registered with .NET Buzz
by Raymond Lewallen.
Original Post: The managed memory heap and its components
Feed Title: Raymond Lewallen
Feed URL: /error.htm?aspxerrorpath=/blogs/raymond.lewallen/rss.aspx
Feed Description: Patterns and Practices, OOP, .Net and Sql
There are the Gen 0, Gen 1, and Gen 2 heaps and the large object
heap. The GC acts on the "managed" or "GC" heap by collecting
unreferenced objects, promoting objects to later generations, and
altering the heap after a collection so memory is contiguous. In the
implementation of .NET Version 1.0, the initial thresholds for
generations 0, 1, and 2 are 256 kilobytes (KB), 2 megabytes (MB), and
10 MB, respectively. Note that the GC can adjust these thresholds
dynamically based on an application's patterns of allocation.
Objects
larger than 85 KB are automatically placed in the large object heap.
These objects are finalized and freed just like objects on the regular
heap. However, the heap is never compacted because shifting these large
blocks of memory would waste a lot of CPU time. Also, the large object
heap is only collected on full GC collections. Note that some MSDN
pages say the large object heap holds objects greater than 20 KB; that
is outdated information.
Loader Heaps are used for loading
runtime CLR structures. The loader heaps hold together the type system,
as opposed to the managed heap which hosts objects. Frequently accessed
items like statics, MethodTables, FieldDescs, and Interface Maps are
allocated on the High Frequency Heap. Less frequently accessed data
structures, like EEClass, ClassLoader, and its look up tables are
allocated on a Low Frequency Heap. Finally, the StubHeap hosts stubs
that facilitate CAS, COM wrapper calls, and P/Invoke. The
HighFrequencyHeap initial reserve size is 32KB and its commit size is
4KB. LowFrequencyHeap and StubHeaps are initially reserved with 8KB and
committed at 4KB.