Discussion about D at a C++ forum

Kiith-Sa 42 at theanswer.com
Mon Jan 9 05:04:27 PST 2012


Jonathan M Davis wrote:

> On Monday, January 09, 2012 00:51:57 Mehrdad wrote:
>> On 1/8/2012 7:09 PM, Vladimir Panteleev wrote:
>> > On Sunday, 8 January 2012 at 23:28:57 UTC, Mehrdad wrote:
>> >> 7. Unstable language. They're currently considering doing things like
>> >> removing "delete" as it's apparently deprecated (which will
>> >> officially make it not usable as an SP language).
>> >> 
>> >>   Looks 100% correct. Removing 'delete' /does/ make D unusable as an
>> >> 
>> >> SP language... unless you ignore the GC completely, which isn't even
>> >> possible, practically speaking.
>> > 
>> > I don't understand how you came to that conclusion? "delete" will
>> > become a standard library (or easily-implemented user) function.
>> 
>> Would it still have the same functionality (i.e. disposing of GC'd
>> objects and reclaiming their memory, as though the GC had done it)?
>> If so, what's the point of removing it in the first place?
>> If not, then I guess my point is obvious.
> 
> I believe that the general idea is that if you want to manually manage memory,
> then you don't use the GC heap, though core.memory.GC will still allow some
> level of manual control for the GC. I'm not aware of any plan to add a
> "delete" function to anything, but if something like that is added, it'll
> probably be to core.memory with the idea that it's there if you really need it
> but that you really shouldn't be using it normally. Explicitly freeing memory
> goes with manually memory management, not garbage collection.
> 
> - Jonathan M Davis

AFAIK, core.memory.GC.free() can be used to manually deallocate GC allocated 
data (you'll have to clear the classes to destroy them, though).

But, correct, if you want manual allocation, you should use manual allocation.
My game project uses GC all over the code - yet most memory is manually 
allocated as the largest allocations are in specific parts of code (mostly 
video related, e.g. textures). This way you get the benefits of both a GC and 
manual allocation.


More information about the Digitalmars-d mailing list