On Wed, 09 May 2012 12:52:43 -0400, Gor Gyolchanyan <[email protected]> wrote:

I got your point. Thanks for the reply!
Wouldn't it make more sense for GC to ignore second deallocation?

The memory may have already been reallocated elsewhere!

If this was the case, data, which is know to become garbage would be
deallocated right away.
On the other hand, I might as well use std.c.stdlib.realloc for these cases.

Do not call C's realloc on GC allocated memory.

The best option is to avoid the GC whatsoever for memory that you want to manage that tightly. Use c's malloc and free, which can be called from the dtor, no problem. If the block has pointers to GC memory, remember to addRoot it (and removeRoot it in destructor).

-Steve

Reply via email to