<div dir="ltr"><div dir="ltr">Did you try disable gc?<div>import core.memory : GC;</div><div>GC.disable;</div><div>aclass a = new aclass();<br></div><div><br></div><div>I believe that your aclass go out of scope and there is no active reference to this so GC can collected it and reuse its memory</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 8, 2018 at 12:50 PM Codifies via Digitalmars-d-learn <<a href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thursday, 8 November 2018 at 11:46:44 UTC, Codifies wrote:<br>
> when creating a new instance of a class<br>
><br>
> aclass a = new aclass();<br>
><br>
> I was under the impression that this created a new chunk of <br>
> memory on the heap...<br>
><br>
> however I'm trying to create this class instance in another <br>
> classes method, I also need to store a pointer to this newly <br>
> created instance in the same method.<br>
><br>
> when I look at the actual value of the pointer, although it <br>
> does change after multiple goes, frequently its the same value.<br>
><br>
> It almost looks like its allocating on the local stack and its <br>
> made a new instance thats entirely local to the factory method.<br>
><br>
> do I need to manually allocate the memory ?? how do I do this? <br>
> how can I allow the GC to clean this up?<br>
><br>
> I'm *really* discombobulated now, as new doesn't seem to be <br>
> working how I thought it did!!!<br>
<br>
I'll try to spin up a minimal example...<br>
</blockquote></div>