Servus,
ich hab ein Problem mit TSearchRec bzw. FindFirst. Trotz des FileClose tritt bei meinem Code immer noch ein MemoryLeak auf. Ich benutze Delphi 7 und FastMM 4.78
Hier ein ganz rudimentärer Beispiel- Code für eine Konsolenanwendung. Jetzt nicht über den Sinn oder Unsinn dieses Codes diskutieren, das hier dient nur der Veranschaulichung, dass da ein Speicherleck auftritt:
Delphi-Quellcode:
program Project1;
{$APPTYPE CONSOLE}
{$I common.inc}
uses
FastMM4 in '..\FastMM\FastMM4.pas',
SysUtils;
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.
FastMM schmeißt folgenden Report raus:
Zitat:
--------------------------------2009/1/16 16:29:18--------------------------------
A memory block has been leaked. The size is: 28
Stack trace of when this block was allocated (return addresses):
402BB4
404265
404290
40A1FC
40A273
40CCF7
7C90DC9C [ZwSetInformationThread]
7C817067 [RegisterWaitForInputIdle]
7C817070 [RegisterWaitForInputIdle]
The block is currently used for an object of class: Unknown
The allocation number is: 97
Current memory dump of 256 bytes starting at pointer address DAB0B0:
01 00 00 00 10 00 00 00 73 76 63 43 41 4C 77 6D 73 52 52 50 2E 6C 6F 67 00 00 B2 50 F8 10 80 80
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
. . . . . . . . s v c C A L w m s R R P . l o g . . ² P ø . € €
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
--------------------------------2009/1/16 16:29:18--------------------------------
This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer):
21 - 28 bytes: String x 1
Note: Memory leak detail is logged to a text file in the same folder as this application. To disable this memory leak check, undefine "EnableMemoryLeakReporting".
Hat von Euch jemand eine Idee, wie ich das Loch stopfen kann? Oder hab ich etwas ganz Elementares übersehen?
Lieben Gruß und vielen Dank im Voraus,
C.