LinkedIn Article to be: Why you need to start moving off C/C++ to D, now.

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 17 08:38:44 PDT 2014


"Araq" <rumpf_a at web.de> wrote:
> The paper focusses on RC vs "tracing". My point is "tracing" vs "copying"
> is another tradeoff. Here is a mark&sweep algorithm:
> 
> - Trace live objects.
> - For each dead object: Deallocate.
> 
> Here is a copying GC:
> 
> - Trace and copy live objects.
> - There is no deallocation step. The old region is free for further usage.

It's more like:
- Allocate a new memory region as big as the current one.
- Trace live objects and copy them to the new region.
- Deallocate old region.

Not only are you deallocating in each step, you are also allocating.

This only pays off if you use very small and short-living objects such that
the deallocation of the whole region is much faster than the deallocation
of the (dead) individual objects and you only have to copy a small fraction
of the objects.

Also be aware that you can only use half of the available (virtual) memory.
And if physical memory is low, you have constant swapping due to the
copying.

Tobi


More information about the Digitalmars-d mailing list