The "no gc" crowd

Michel Fortin michel.fortin at michelf.ca
Wed Oct 9 10:32:10 PDT 2013


On 2013-10-09 14:52:35 +0000, Manu <turkeyman at gmail.com> said:

> I suspect there are plenty of creative possibilities that could be applied
> to reducing the pool of potential circular-references to as small a pool as
> possible.

I'm more pessimistic than you on this. Cycles can only be detected at 
runtime unless we make dramatic changes to the memory model. You can 
find cycles by scanning at intervals, as the GC does. Or you could 
detect them by updating a dependency graph each time you assign a value 
to a pointer. The dependency graph would have to tell you whether 
you're still connected to a root. When all root connections are severed 
you can free the object. I doubt the overhead would make this later 
idea practical however.

Weak-autonulling pointers are much cheaper. I'd suggest using one of 
the above methods as debugging aid to find cycles, and then manually 
insert weak pointers where needed to break those cycles. Either that, 
or leave the GC on if you don't mind the GC.


> It's simply not feasible to have machine scanning 4-6 gigabytes of
> allocated memory looking for garbage.

Agree.


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



More information about the Digitalmars-d mailing list