C++ and D @ stackoverflow

Leandro Lucarella llucax at gmail.com
Sat Jun 12 18:06:18 PDT 2010


Andrei Alexandrescu, el 12 de junio a las 07:20 me escribiste:
> Leandro Lucarella wrote:
> >Andrei Alexandrescu, el 12 de junio a las 00:32 me escribiste:
> >>BCS wrote:
> >>>http://stackoverflow.com/questions/3024136/link-compatibility-between-c-and-d
> >>I just posted an answer that contains a couple of news.
> >
> >As I said with your new RefCounted implementation, unless I'm missing
> >something, there will be problems if you store pointers (or objects that
> >have pointers) to the GC heap, as you never communicate with the GC.
> 
> Could you please give an example? Thanks!

I guess is clear from the suggestion by Walter, but basically you are
not telling the GC about the roots outside the stack(s) and static data.
If the GC can't reach an object from that roots, but those objects are
still pointed by the malloc()ed memory, the GC will recycle the
"dangling" objects (from the GC POV) and bad things will happen (memory
corruption, basically).

I hope it clarifies.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Ladrón no es cualquiera, ladrón es quien usurpa el bien ajeno en
beneficio propio, si no, no.
	-- Ricardo Vaporeso


More information about the Digitalmars-d mailing list