<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 27, 2017 at 1:41 PM, Jonas Maebe <span dir="ltr"><<a href="mailto:jonas@freepascal.org" target="_blank">jonas@freepascal.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> It is defined as "if the instance is not nil, then it calls the destroy method, and next it calls FreeInstance". You could override FreeInstance to not free memory on any platform.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
However, if JVM free method would at least reset "o" reference to nil,<br>
then the semantic of "o" being an invalid object remains.<br>
</blockquote>
<br></span>
There is no need to do this.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It also suggests to the garbage collector that the memory could be<br>
recycled earlier, that the variable leaves the scope.<br>
</blockquote>
<br></span>
That is true.</blockquote><div><br></div><div>How about moving "nil"-ing of the reference into default FreeInstance for JVM target?</div><div><br></div><div>The whole point of removing the reference, is to let the collector to dispose of the object as soon as possible.<br></div><div><br></div><div>I'm thinking about classes that consume a lot of (system) resources and release them only in during destruction.</div><div>Releasing them as soon as possible **might** be a benefit for the code behavior over all.</div><div><br></div><div>thanks,</div><div>Dmitry</div></div></div></div>