DIP74: Reference Counted Class Objects
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 27 15:04:14 PST 2015
On 2/27/15 2:03 PM, ted wrote:
> I'm still a bit confused here: the examples in DIP74 showed the freeing of
> memory via 'GC.free(cast(void*) this);' - so I had assumed that
> 'Widget a = new Widget' would be the way it was created? (and that
> automatically uses GC - or is this what I am missing?)
The GC allows both manual freeing and via tracing. So after allocating
with new, a user may either leave it to the GC or call the destructor
followed by GC.free.
> I can see how a system that used (for example) malloc/calloc/free would
> work, I'm just querying the consistency of the examples within DIP74?
GC.malloc/GC.free and malloc/free should both work.
Adnrei
More information about the Digitalmars-d
mailing list