Memory problem with Zeos Access
Original Reporter info from Mantis: gbouille
-
Reporter name:
Original Reporter info from Mantis: gbouille
- Reporter name:
Description:
I use Zeos Acces components with Lazarus to transfert data from one database to a another with some computation. I have some problem. The date fields reading are not correct with FPC 2.0.2 but it's ok with FPC 2.0.3. (some rounding problem but that's another bug report).
The memory problem is that after a TZReadOnlyQuery.Close the memory is not free. This problem occurs with FPC 2.0.3, 2.0.4 rc2, 2.1.1 but not with FPC 2.0.2. This is why I think this is a FPC bug, not a Lazarus or a Zeos one.
As I tranfert mega's of data on several tables, the memory uses by the program grows a lot until crash.
Additional information:
[...]
SQLQSource := TZReadOnlyQuery.Create(Application);
SQLQSource.Connection := ZConnectionSource;
SQLQCible := TZQuery.Create(Application);
SQLQCible.Connection := ZConnectionCible;
ZTableCible := TZTable.Create(Application);
ZTableCible.Connection := ZConnectionCible;
SQLQSource.SQL.Clear;
SQLQSource.SQL.Add('select *');
SQLQSource.SQL.Add(' from INDIVIDU where KLE_DOSSIER=' + dossiers);
SQLQSource.open;
if (SQLQSource.RecordCount > 0) then
begin
ZTableCible.TableName := 'INDIVIDU';
ZTableCible.Open;
ZTableCible.Edit;
while (not SQLQSource.eof) do
begin
ZTableCible.Insert;
ZTableCible.FieldByName('CLE_FICHE').AsInteger := NouvCle;
ZTableCible.FieldByName('KLE_DOSSIER').AsString := dossierc;
ZTableCible.FieldByName('CLE_IMPORTATION').AsInteger := NouvCle;
if not SQLQSource.FieldByName('CLE_PERE').IsNull then
ZTableCible.FieldByName('CLE_PERE').AsInteger := SQLQSource.FieldByName('CLE_PERE').AsInteger;
if not SQLQSource.FieldByName('CLE_MERE').IsNull then
ZTableCible.FieldByName('CLE_MERE').AsInteger := SQLQSource.FieldByName('CLE_MERE').AsInteger;
[...]
if not SQLQSource.FieldByName('SOURCE').IsNull then
begin
Tampon := TMemoryStream.Create;
try
TBlobField(SQLQSource.FieldByName('SOURCE')).SaveToStream(tampon);
tampon.Seek(0, soFromBeginning);
TBlobField(ZTableCible.FieldByName('SOURCE')).LoadFromStream(tampon);
finally
tampon.Free;
end;
end;
if not SQLQSource.FieldByName('COMMENT').IsNull then
begin
Tampon := TMemoryStream.Create;
try
TBlobField(SQLQSource.FieldByName('COMMENT')).SaveToStream(tampon);
tampon.Seek(0, soFromBeginning);
TBlobField(ZTableCible.FieldByName('COMMENT')).LoadFromStream(tampon);
finally
tampon.Free;
end;
end;
[...]
ZTableCible.Post;
SQLQSource.Next;
end;
ZTableCible.ApplyUpdates;
ZTableCible.Close;
end; // fin de If (SQLQSource.RecordCount>0)
SQLQSource.Close;
//Table MULTIMEDIA
SQLQSource.SQL.Clear;
SQLQSource.SQL.Add('select *');
SQLQSource.SQL.Add(' from MULTIMEDIA where MULTI_DOSSIER=' + dossiers);
SQLQSource.open;
if (SQLQSource.RecordCount > 0) then
begin
I := 0;
ZTableCible.TableName := 'MULTIMEDIA';
ZTableCible.Open;
ZTableCible.Edit;
while (not SQLQSource.eof) do
begin
[...]
SQLQSource.Next;
end;
ZTableCible.ApplyUpdates;
ZTableCible.Close;
end; // fin de If (SQLQSource.RecordCount>0)
SQLQSource.Close;
//Table ADRESSES_IND
SQLQSource.SQL.Clear;
[...]
And so on.
As I use blobs, the memory grows quite quickly.
Mantis conversion info:
- Mantis ID: 7209
- Version: 2.0.4
- Monitored by: » luizamerico (Luiz Americo)