D1 garbage collector + threads + malloc = garbage?

Sean Kelly sean at invisibleduck.org
Sat Dec 12 18:03:10 PST 2009


Walter Bright Wrote:

> Sean Kelly wrote:
> > Walter Bright Wrote:
> >> No, because the thread doing the GC collection has locked the GC.
> >> Any other thread attempting to alloc will wait on that lock. There
> >> is only one GC lock.
> > 
> > Yeah, but it releases the lock when the collection completes, and the
> > it retries the allocation to actually obtain memory.  If the lock
> > were held until the thread exited the GC code completely there
> > wouldn't be a problem.
> 
> I don't understand why there is a problem with this. When the collection 
> is complete, release lock, then get lock again for allocation, if the 
> allocation fails, then go for another collection.

Ah, I didn't realize the allocation call backed up that far after the collection.  It's been a while since I looked at the code.



More information about the Digitalmars-d mailing list