[concurrency-interest] Garbage First vs a counting collector

Gregg Wonderly gregg at cytetech.com
Thu Mar 26 17:33:44 EDT 2009


Florian Weimer wrote:
> * Jeremy Manson:
> 
>> 3) In the case where you are writing to a region you haven't already
>> written, it is 2) plus a memory write to record the fact that you are
>> writing to another region.
> 
>> Even 3) is orders of magnitude cheaper than a CAS.  I'm not sure how
>> expensive 4) is, but it doesn't happen all that often.
> 
> Depends on the CAS implementation.  CAS (and presumably atomic
> increment/decrement on x86) on non-shared cache lines can be made
> quite cheap.
> 
> One thing to consider is that reference counting only solves the
> problem of reachability (ignoring cycles).  It does not help with
> fragmentation.

Yes, in my implementation, I was using the malloc libraries and just allowing 
them to internally manage grouping.  My collector had nothing to deal with 
compaction or otherwise manage fragmentation.

In particular there are very real issues where small amounts of memory are used 
and freed frequently with just as many larger chunks of memory being allocated 
more permanently.  String concatenation from loops like

	InputStream rd = ...
	int i;
	byte buf[] = ...
	String str = "";
	while( ( i = rd.read(buf) ) > 0 ) {
		str += new String( buf, 0, i );
	}

are great at creating small free structures intermingled with larger permanent 
structures which can quickly fragment memory into unusable segments.

Compaction is something that is vital to long lived highly dynamic application.

Gregg Wonderly


More information about the Concurrency-interest mailing list