[yunqa.de] TDISQLite3Statement memory leak?

  • From: "Clyde England" <clyde@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sun, 06 Jul 2008 18:04:47 +0800

I have a database with a  table that has "memo" type fields (variable length 
text that average out to about 4000 characters per record)

I am using TDISQLite3Statement to access the data, but the memory in my 
application keeps increasing and never returns.

The following example procedure is contrived but illustrates the code I am 
using to duplicate

I create a procedure called leak (dbs is a database opened previously), then 
run it multiple times as in:

for x := 1 to 10000 do leak;

I can't seem to find examples on the correct use of TDISQLite3Statement so 
perhaps there is something wrong with my code?

Interestingly if I substitute stmt2.close with stmt.free I don't get the memory 
leak, but I have never seen any examples that explicitly call the free method 
like this and am concerned this may cause other issues.

However from my reading of the list stmt.close is the correct way to finish off

Should the close method finalize things and free up memory?

Is this a bug, or is there a problem in my code?


  procedure leak;
      stmt : TDISQLite3Statement;
      i : integer;
      data : string;
      stmt := dbs.prepare16('select longdescription from cmemo limit 1');
      i := stmt.step;
      while i = sqlite_row do
          data := stmt.Column_Str16(0);
           i := stmt.step;

Delphi Inspiration mailing list

Other related posts: