Es liegt daran, dass Du globale Variablen verwendest. Lagerstr Du alles in eine separate Prozedur aus, gibt es kein Speicherleck:
Delphi-Quellcode:
procedure FindLogFiles;
var
loc_path: String;
loc_dummy: String;
loc_sr: TSearchRec;
begin
loc_path := 'C:\Temp\';
loc_dummy := 'TestFile.log';
if FindFirst(loc_path + '*.log', faAnyFile - faDirectory, loc_sr) = 0 then
try
repeat
if (SameText(loc_dummy, loc_sr.Name)) then begin
Writeln('Found file: ' + loc_sr.Name);
end;
until (FindNext(loc_sr) <> 0);
finally
FindClose(loc_sr);
end;
{ Free memory of string vars }
loc_path := '';
loc_dummy := '';
end;
begin
FindLogFiles;
end.
Oder, alternativ mit Finalize(loc_sr).