The GC and performance, but not what you expect

Rainer Schuetze via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 10 23:02:19 PDT 2014



On 10.06.2014 17:15, Sean Kelly wrote:
> On Thursday, 29 May 2014 at 23:39:02 UTC, Marco Leise wrote:
>>
>> Nice try, but destructors called by the GC are currently
>> effectively @nogc. So don't try that at home.
>
> When did that happen?  Some effort was made at one point to ensure that
> allocations worked from dtors.  Not that I'm in favor, but...

I don't think that ever worked, at least for the last couple of years.

Threads run during sweep, and an allocation during the collection might 
pass the gc-lock because it allows recursive locking in the same thread, 
but if the allocation hits an empty free-list, it will try to run 
another collection which will cause the InvalidMemoryOperationError.

If it happens to allocate from a free-list, it will likely cause memory 
corruption, because sweeping won't know it has been allocated (mark and 
freebits not updated), and put it back into a free list.


More information about the Digitalmars-d mailing list