I have some Delphi 6 code that allocates memory using New and frees it using Dispose. I have stepped through the code and see that both New and Dispose actually do get called.
I am wondering why FastMM is reporting a memory leak, even though Dispose is called. Could it be related to the fact that the item being disposed is in the var section?
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);
Here is the information from 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--------------------------------
精彩评论