More radical ideas about gc and reference counting

monarch_dodra via Digitalmars-d digitalmars-d at puremagic.com
Thu May 1 03:10:20 PDT 2014


On Thursday, 1 May 2014 at 01:04:08 UTC, Steven Schveighoffer 
wrote:
>> That means classes that need cleanup (either directly or by 
>> having fields that are structs with destructors) would need to 
>> garner that by other means, such as reference counting or 
>> manual. We're considering deprecating ~this() for classes in 
>> the future.
>
> So essentially, any class with a dtor needs reference counting? 
> How does one clean up a cycle of them?

Yeah, what he said. This has me very worried. Making cycles is 
actually incredibly easy. Any "inteligently" implemented 
"node-based" data structure, implemented with classes, such as a 
linked list, a tree or a graph, is virtually guaranteed to have a 
cycle somewhere...

*Or*

is the idea that reference counting only works for finalization, 
but the memory is still managed by the GC? In that case, the 
destructors would leak, but the memory still be released?

That's still bad, of course, but not "as" bad...


More information about the Digitalmars-d mailing list