gc : gen 0,1,2 heaps, loh

J

John Grandy

Are Gen 0, Gen 1, Gen 2 heaps and Large Object Heaps physically contiguous ?
Or are these abstract representations of groups of allocated segments in the
general heap ? More specifically, are the segments physically contiguous
within each heap ? And are the heaps physically contiguous ?

So, G1,G2,G3 heap max size, etc. (and LOH max size) are proportionate to the
# of general heap memory segments currently allocated for each of these GC
heaps ?

If the GC heaps are not physically contiguous memory spaces, by what method
does generational promotion reduce fragmention in the preceding heaps ? (
scenario 1 : a just de-referenced object is added to gen 1 heap; scenario
2: a gen 1 heap object is promoted to gen 2 heap )
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

John said:
Are Gen 0, Gen 1, Gen 2 heaps and Large Object Heaps physically contiguous ?
Or are these abstract representations of groups of allocated segments in the
general heap ? More specifically, are the segments physically contiguous
within each heap ? And are the heaps physically contiguous ?

The generational heaps are certainly contigous. The idea is that
allocating memory is a very simple process, where the next free block is
always at the top of the heap.

The large objects heap is probably not contigous, as it expands when needed.
So, G1,G2,G3 heap max size, etc. (and LOH max size) are proportionate to the
# of general heap memory segments currently allocated for each of these GC
heaps ?

If the GC heaps are not physically contiguous memory spaces, by what method
does generational promotion reduce fragmention in the preceding heaps ? (
scenario 1 : a just de-referenced object is added to gen 1 heap; scenario
2: a gen 1 heap object is promoted to gen 2 heap )

The general method to avoid fragmentation is to move all used objects to
the next generation and wipe the current generation totally clean. As
memory only is allocated from the top of the heap, it's actually never
fragmented at all. It just contains used and unused objects, and only
the garbage collector knows and cares if the objects are used or not.
 
B

Ben Voigt [C++ MVP]

John Grandy said:
Are Gen 0, Gen 1, Gen 2 heaps and Large Object Heaps physically contiguous
? Or are these abstract representations of groups of allocated segments in
the general heap ? More specifically, are the segments physically
contiguous within each heap ? And are the heaps physically contiguous ?

By "physically", do you really mean physically? You shouldn't care. .NET
runs only in user-mode which has only logical addresses. The only time the
physical addresses matter are on NUMA machines, and even then the ordering
within each node doesn't matter. RAM is "random-access", after all, you
gain nothing from allocating physical pages sequentially except smaller page
tables, and the only way to control that from user-space is to precommit
large blocks which is in general a very bad idea, especially for a
general-purpose platform like .NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top