Is there a modern GC for D?

Michel Fortin michel.fortin at michelf.com
Fri Feb 12 16:47:17 PST 2010


On 2010-02-12 18:08:09 -0500, "Robert Jacques" <sandford at jhu.edu> said:

> On Wed, 10 Feb 2010 09:51:37 -0500, Leandro Lucarella 
> <llucax at gmail.com>  wrote:
> 
>> There is a very simple concurrent GC model using fork()[1]. This is Unix  only
>> though (and very dependent on how efficiently fork() is implemented in  the
>> OS). I'm working (very slowly :) on implementing a GC based on this
>> algorithm.
>> 
>> No races, almost no synchronization. If the OS uses COW when fork()ing (I
>> guess every modern OS does that), the only drawback is the copying of
>> changed pages.
>> 
>> [1] Nonintrusive Cloning Garbage Collector with Stock Operating System
>>     Support.
>>     http://www.cs.purdue.edu/homes/grr/snapshot-gc.ps
>> 
> 
> Cool. Hadn't thought of something so simple. I just watched a channel 9 
>  blog  
> (http://channel9.msdn.com/shows/Going%20Deep/Mark-Russinovich-Inside-Windows-7-Redux/) 
>  and about half-way through they talk about new process reflection  
> capabilities in Windows 7, which are an extension of fork, which 
> they've  had for a while (for posix compatibility, etc). Also, the 
> PAGE_WRITECOPY  protection should also allow this to work on Windows, 
> at a finer grain.

It looks cool indeed. I was a little wary for ill effects at first, so 
I attempted to insert an innocuous:

	if (fork() == 0) {
		sleep(1); // do mark and sweep and return the result to the parent process.
		exit(0);
	}

in a (single-threaded) Cocoa application. No ill effect found (as long 
as you don't forget the exit(0)). I wonder how it'd fly on Windows 
though, isn't process creation a little more heavyweight?

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list