On Thursday, December 27, 2012 16:00:58 FG wrote: > On 2012-12-27 15:31, bearophile wrote: > > delete is deprecated in D. There is destroy(), and a replacement for > > delete in the memory/GC module. > > destroy() had no effect on program's behavior, even the docs state that "it > does not initiate a GC cycle or free any GC memory". > So I hope delete will still remain an option. > Very useful for freeing such large chunks like in this example. > > What do you mean as the delete replacement?
The idea is that if you want to be manually freeing memory, you shouldn't be using GC memory in the first place. It's unsafe to be freeing it. Let the GC do that. If you want to manually manage memory, then manually manage it with malloc and free. If you really need to, then core.memory has the functions for managing the GC's memory, but you really shouldn't be doing that normally. Manual memory management should become easier once custom allocators are sorted out, since right now, if you want objects, you need to use emplace to turn the malloced memory into a proper object, and it's definitely more of a pain than using new with the GC. But it's still not a good idea in general to try and do manual memory management on GC memory. - Jonathan M Davis
