Manual memory management in D2

Petr Janda janda.petr at gmail.com
Mon Jul 26 05:55:13 PDT 2010


So what was the conclusion(if any) reached on how to allocate/deallocate objects on the C heap -
equivalent of C++ new and delete keywords?

The summary i've reached so far:

1) "new" allocates on GC heap, and manually freeing memory allocated to GC's heap is not a good
idea be it either via delete or GC.free()

2) clear() is the safe "delete" for objects allocated on the GC heap

3) There is an emplace() function, what does that do again? There is a serious problem caused by
lack of easily accessible documentation.

4) Whats the correct procedure for using custom allocators? ie. i could write a D equivalent of
std::memory

5) Which parts of D and Phobos rely on GC and cannot be used in classes that manage their own
resources for example through RAII?

We really need an up to date page describing D's capabilities in the area of manual memory
management.

Thanks,
Petr


More information about the Digitalmars-d mailing list