Hi there,
I'm experiencing a strange memory behaviour using the following code. The table is holding about 400.000 records:
//----------------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
aQuery: TZQuery;
begin
aQuery := TZQuery.Create(nil);
aQuery.Connection := G_DBConnection;
try
aQuery.SQL.Text := 'SELECT * FROM table1234;';
aQuery.Open;
try
while not aQuery.EOF do
begin
// ...
aQuery.Next;
end;
finally
aQuery.Close;
end;
// ...
finally
aQuery.Free;
end;
end;
//----------------------------------------------------------------------
I'm using ZEOSDBO-6.6.4-stable under Delphi 7, the database is postgreSQL 8.4.0.1.
The memory increases massively by calling "aQuery.Next" and is never totally released (only when you close the application).
One should think that if you call "aQuery.Next" on an already cached ResultSet the memory doesn't increase much further, but it does.
FastMM is reporting no memory leaks though...
Any ideas?
Thanks in advance!
Memory issue
Moderators: gto, EgonHugeist
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Using BLOB's? Then have a look at http://zeosbugs.firmos.at/view.php?id=207 . Does it fix the issue?
Mark
Mark
Thanks for the reply, but there aren't any BLOB fields involved.
It's even behaving like that if the table has just one column (e.g. "integer", and the mentioned 400.000 records).
Meanwhile I noticed that if I use "TZReadOnlyQuery" instead of "TZQuery" the memory isn't going that far up by calling "aQuery.Next" repeatedly and it is also released completely by calling "aQuery.Close".
However, the behaviour of TZQuery seems strange to me ...
It's even behaving like that if the table has just one column (e.g. "integer", and the mentioned 400.000 records).
Meanwhile I noticed that if I use "TZReadOnlyQuery" instead of "TZQuery" the memory isn't going that far up by calling "aQuery.Next" repeatedly and it is also released completely by calling "aQuery.Close".
However, the behaviour of TZQuery seems strange to me ...
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
With calling Next TZQuery caches the data internally until the query is closed (and maybe until the query is freed, not sure about that). The TZReadonlyQuery always fetches the data when needed and doesn't keep it in his internal buffer. When only moving through the resultset once this is OK.
In the pure readonly+forwardonly situation you might even try to use the dbc layer, which has less overhead, but doesn't have the TDataset behaviour.
Mark
In the pure readonly+forwardonly situation you might even try to use the dbc layer, which has less overhead, but doesn't have the TDataset behaviour.
Mark
Thanks for the reply!
The ResultSet seems to be cached in both cases when calling Open (TZQuery and TZReadOnlyQuery) whereas in case of TZQuery memory keeps going up further by calling Next.
The problem with TZQuery is that memory definitely ISN'T released by calling Close and not even by calling Free... only when terminating the application.
Using the Dbc-Layer makes no difference.
The ResultSet seems to be cached in both cases when calling Open (TZQuery and TZReadOnlyQuery) whereas in case of TZQuery memory keeps going up further by calling Next.
The problem with TZQuery is that memory definitely ISN'T released by calling Close and not even by calling Free... only when terminating the application.
Using the Dbc-Layer makes no difference.