Hello People<div><br></div><div>I was just trying out custom memory allocation/deallocation that can be found on the link <a href="http://www.d-programming-language.org/memory.html#newdelete">http://www.d-programming-language.org/memory.html#newdelete</a></div>

<div><br></div><div>The problem is that the delete function is never getting called. I have put an example test case at the end of the email.</div><div><br></div><div>Any ideas?</div><div><br></div><div>Regards</div><div>

- Puneet</div><div><br></div><div><br></div><div><br></div><div><div>import core.memory : GC;</div><div>import std.stdio;</div><div>import std.exception;<span class="Apple-tab-span" style="white-space:pre">                </span>// enforce</div>

<div><br></div><div>class Foo {</div><div>  string value = ".";</div><div><br></div><div>  new(size_t sz) {</div><div>    write("+");</div><div>    void* p = enforce(GC.malloc(sz),</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>      "Out of memory while allocating Foo");</div>

<div>    GC.addRange(p, sz);</div><div>    return p;</div><div>  }</div><div><br></div><div>  delete(void* p) {</div><div>    write("-");</div><div>    if (p) {</div><div>      GC.removeRange(p);</div><div>      GC.free(p);</div>

<div>    }</div><div>  }</div><div>}</div><div><br></div><div>void main() {</div><div>  for (size_t i = 0; i < 32; ++i) {</div><div>    Foo foo = new Foo();</div><div>    write(foo.value);</div><div>  }</div><div>}</div>

</div><div><br></div>