我有一些Delphi 6代码,它使用New分配内存并使用Dispose释放它。我已经逐步完成了代码,看到New和Dispose实际上都被调用了。
我想知道为什么FastMM报告内存泄漏,即使调用了Dispose。是否与被处置的物品在var部分有关?
type TRunP = record
channels : Word; (* channels for program *)
GCharH : Word; (* Character Height *)
GCharW : Word; (* Character Width *)
... [snip]
end;
...
PRunPBuf = ^TRunP; //record pointer
...
var
ptrRunPBuf: PRunPBuf;
...
New(ptrRunPBuf); //here is the problem, FASTMM claims this was never disposed, but dispose was called without error.
...
Dispose(ptrRunPBuf);
以下是来自FastMM的信息。
--------------------------------2011/10/4 16:29:08--------------------------------
A memory block has been leaked. The size is: 276
This block was allocated by thread 0x1BBC, and the stack trace (return addresses) at the time was:
40002FCF [System][@GetMem]
6243EB [dir\mfs1.pas][MFshell1][TfrmM.FormCreate][1806]
400EDDA7 [Forms][TCustomForm.DoCreate]
400EDA1A [Forms][TCustomForm]
7E428EAB [Unknown function at DefWindowProcW]
7C90D98A [ZwQueryVirtualMemory]
7C80BA5D [VirtualQueryEx]
7C80BA86 [VirtualQuery]
1148FD9 [GetFrameBasedStackTrace]
114901C [GetFrameBasedStackTrace]
1149336 [GetRawStackTrace]
The block is currently used for an object of class: Unknown
The allocation number is: 62982
Current memory dump of 256 bytes starting at pointer address 7FF40410:
44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00
44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00
44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00
44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00
44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00
44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00
44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00
44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00 44 99 63 00
D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c .
D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c .
D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c .
D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c .
D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c .
D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c .
D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c .
D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c . D ™ c .
--------------------------------2011/10/4 16:29:08--------------------------------