Miscellaneous memory management questions

Steven Schveighoffer schveiguy at yahoo.com
Thu Sep 2 06:37:56 PDT 2010


On Thu, 02 Sep 2010 09:31:22 -0400, Simen kjaeraas  
<simen.kjaras at gmail.com> wrote:

> Peter Alexander <peter.alexander.au at gmail.com> wrote:
>
>> Hi,
>>
>> I've not been staying up to date on the new/delete discussions and  
>> related memory management issues, so I have a few questions.
>>
>> 1. How do I disable the GC?
>
> In a way, you don't. You can, however, replace it with a stub GC.

You can disable it (for most intents and purposes) at runtime:

http://www.dsource.org/projects/druntime/browser/trunk/src/core/memory.d#L77

>> 2. Can I override new?
>
> Yes. However, this is no longer mentioned on
> http://digitalmars.com/d/2.0/class.html, so it might be intended not to
> be there anymore.
>
> class foo {
>      new( uint size ) {
>         return malloc( size );
>      }
> }

This is going to be deprecated.  Use emplace instead.

-Steve


More information about the Digitalmars-d mailing list