0

我有一些 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--------------------------------
4

0 回答 0