Czesc. Mam problem z czyszczeniem pamięci po wczytaniu z bazy danych 100 tys rekordów ( używam wątku żeby podczas wczytywania nie zatrzymywać głównej formy). Przesylam mój kod zebyście mogli mi pomóc. nie wiem gdzie jest błąd
procedure TWczytywanieADO.Execute;
var
I : integer;
begin
try
NameThreadForDebugging('WczytywanieADO');
{ Place thread code here }
ConnectionString := TMSConnection.Create(nil);
with ConnectionString do
begin
ConnectString := dm.ADOConnectionServer.ConnectString;
Pooling := true;
end;
ado := TMSQuery.Create(nil);
with ado do
begin
try
NonBlocking := true;
Connection := ConnectionString;
SQL.Text := SQLText^;
FetchAll := true;
Name := 'IQWatek';
repeat
if Formatka^ = nil then
sleep(60)
else if (DSource^.DataSet <> NIL) then
sleep(60)
else if DSource^.DataSet <> ado then
begin
EnterCriticalSection(cls);
DSource^.DataSet := ado;
LeaveCriticalSection(cls);
Open;
repeat
until THGrid^.RowCount > ado.RecordCount - 1;
ThGrid^.Enabled := true;
end;
until THGrid^.RowCount > ado.RecordCount - 1;
finally
EnterCriticalSection(cls);
DSource^.Enabled := false;
DSource^.DataSet := nil;
LeaveCriticalSection(cls);
end;
end;
finally
// ado.Free;
DeleteCriticalSection(cls);
FreeMem(Formatka);
FreeMem(ThGrid);
FreeMem(sqltext);
FreeMem(DSource);
FreeandNIl(ado);
end;
end;