[fpc-pascal] Reference Counting
Werner Van Belle
werner at yellowcouch.org
Mon Apr 5 08:05:05 CEST 2010
Graeme Geldenhuys wrote:
>> Test:=nil;
>>
>
> This causes a memory leak - you did not actually free the class
> instance. You need to call: Test.Free;
>
Of course I didn't call free; I was hoping that the reference counter
would solve that little problem. If I need to free stuff myself, I don't
really need a reference counter. In any case, thanks for the answer. I
will give it a try and see what it gives
>> Pest:=nil;
>>
>
> Pest was just a reference pointer to the first instance, so no need to
> free it. But setting it to nil after Test was freed is a good habit.
>
I'm not sure that is correct. Once you free Test, Pest still points to
the same non existing object and you can use assigned to check it,
--
http://werner.yellowcouch.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100405/d394c8ed/attachment.sig>
More information about the fpc-pascal
mailing list