D1 garbage collector + threads + malloc = garbage?

Walter Bright newshound1 at digitalmars.com
Sat Dec 12 14:27:57 PST 2009


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.



More information about the Digitalmars-d mailing list