<div dir="ltr"><div dir="ltr">On Fri, Oct 23, 2020 at 8:20 AM frame via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:  </div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> Even this is a "intelligent" <br>
feature by the compiler for non reachable code like that loop, <br>
it's still confusing. There are maybe situations while the object <br>
should stay in background, eg. socket related/event stuff. If <br>
there is a valid pointer, there is no excuse to reap it.<br><br></blockquote><div><br></div><div>There is no use of foo anywhere so there is no reason to not collect it. You even does not need to have while in your code:</div><div><br></div><div>void main() {<br>     auto foo = Bar.create();<br>     writefln("address: %s", foo.__vptr);<br>     GC.collect();<br>     Thread.sleep(1.seconds);<br>     //foo.sayHello(); // if uncommented GC would not call destructor until end of main<br>}<br></div></div></div>