[yunqa.de] Re: TDisqlite3Statement.free - test if "freed"

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sat, 18 Jul 2009 12:55:11 +0200

Hello Clyde England,

>After I have finished with a  TDisqlite3Statement I use the free
>method to release the corresponding memory. This works fine.
>
>However, I have a need later on in the code to see if this object has
>actually been freed or not. I can't test for = "nil" because my
>understanding is that the free method just leaves a "dangling
>pointer".

This is just the normal Delphi behaviour. It is unrelated to 
TDISQLite3Statement.

>My solution is to now always use FreeandNil() for clean up so I can
>then test for "nil". So instead of something like:
>
>stmt.free;
>
>I now use:
>
>Freeandnil(stmt);

Delphi's FreeAndNil procedure was introduced for just this purpose.

>My questions:
>
>1. Is there a better way to test if TDisqlite3Statement has been freed.?

If you are really worried about, use a memory leak checker, at least for 
debugging. FastMM comes to mind.

>2. Are there any hidden problems (or performance issues) with using
>Freeandnil to free a TDisqlite3Statement

No. FreeAndNil works with TDISQLite3Statement just as it does with other 
TObject descendants.

>3. Should I just be using the following code instead:
>
>stmt.free;
>stmt := nil;

I do not see any advantage to this over FreeAndNil.

Ralf 

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: