A question/suggestion regarding the GC

Sean Kelly sean at invisibleduck.org
Sat Sep 20 20:03:11 PDT 2008


bearophile wrote:
> Jarrett Billingsley: 
> 
>> If your _entire_ program were in SafeD, however, you could come up with a new GC that could do heap compaction and the like.<
> 
> From what I have read the compacting is very important, without it the heap may become quite fragmented so the program may become very slow.
> http://deepheap.blogspot.com/2008/09/ghost-in-java-virtual-machine.html
> This may mean that currently D may be not much fit to write a program that has to run no-stop for days, because I think there are no ways to avoid high fragmentation of the heap.

The Phobos/Tango GC uses pools of fixed-size memory blocks that increase 
in powers of two, so 16, 32, 64, etc, bytes.  Fragmentation is basically 
impossible with this design.

More generally, there are papers in print showing that fragmentation in 
allocators is a solved problem, so in general I wouldn't worry about it 
these days anyway.  If there are Java VMs with fragmentation issues then 
I'd say their allocators are junk.

That said, compaction can also reduce the number of page faults in some 
apps as well as reduce the process memory footprint, so there are 
definitely advantages to it even when fragmentation is not a concern.


Sean


More information about the Digitalmars-d-learn mailing list