Andrei Alexandrescu, el 23 de abril a las 12:48 me escribiste: > Brad Roberts wrote: > >Leandro Lucarella wrote: > >>Now in Tango/Druntime you already can use a dummy GC that all it does is > >>calling C malloc/free for gc_malloc/gc_free, exactly for this purpose, so > >>what -nogc should do in that case is just link against the "stub" GC > >>instead to the "basic". > >This claim really needs to stop. You can't just swap from the normal gc > >to the stub gc an expect your app to use malloc/free and behave exactly > >as it did before. No, it'll leak. Free will never be called (outside > >the rare case of an explicit delete). Normal apps expect implicit > >cleanup to be invoked by the gc which will never happen in the stub. > >That's fine in tiny apps, or apps that carefully manage their own > >memory, but then you weren't using the gc in the first place for those apps. > > Totally agreed. I've always wondered what the purpose of the stub GC was in > druntime. "We can implement an appallingly crappy allocation model" is the > only > message I'm getting. > > Andrei
>From the stub GC documentation: This module contains a minimal garbage collector implementation according to published requirements. This library is mostly intended to serve as an example, but it is usable in applications which do not rely on a garbage collector to clean up memory (ie. when dynamic array resizing is not used, and all memory allocated with 'new' is freed deterministically with 'delete'). I think being an example is just a good enough reason (it was useful for me at least). The other use you may like it or not, but is there. And may I ask what it would happen if I do this with your "-nogc" proposal? class A { B b; } class B { A a; } A a = new A; a.b = new B; a.b.a = a; ? Wont this leak? Are you planning to make a backup tracing collector to fix cycles maybe? Because I don't think using a naive reference counting will avoid leaks as easy as you put it... RC is not *that* simple. -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ----------------------------------------------------------------------------