<br><br><div class="gmail_quote">On 22 October 2011 08:14, Ludo Brands <span dir="ltr"><<a href="mailto:ludo.brands@free.fr">ludo.brands@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">> Nil is not a routine, it is a value, it means that the object<br>
> is empty, it does not exist / is not allocated. Nil in<br>
> existing implementations that I know is represented by the value zero.<br>
><br>
> The typical life-cycle of a object is:<br>
><br>
> MyObject := TMyObject.Create;<br>
> try<br>
>   MyObject.DoSomething();<br>
> finally<br>
>   MyObject.Free;<br>
> end;<br>
><br>
<br>
</div>One pitfall: the variable MyObject before MyObject := TMyObject.Create; is<br>
undefined and not necessarily nil. Variables are not initialized by default<br>
and can contain anything. In general, MyObject.Free does not set MyObject to<br>
nil neither.  Good practice is to initialize pointer variables to nil and<br>
resetting them to nil after freeing them whenever assigned() or <>nil is<br>
going to be used.<br>
<font color="#888888"><br></font></blockquote><div><br>Does that mean that Free itself reclaims the memory used by the object's fields and properties but does not release the memory used by the TObject or pointer itself, where as setting it to nil or executing Destroy does, or does Destroy do something different?<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><font color="#888888">
Ludo<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Frank Church<br><br>=======================<br><a href="http://devblog.brahmancreations.com">http://devblog.brahmancreations.com</a><br>