Delphi FastMM4如何读取MemoryManager_EventLog.txt?

时间:2019-06-19 12:54:54

标签: delphi memory-management memory-leaks fastmm

我已将FastMM4添加到我的项目中以检测内存泄漏

program MyProg;

uses
  {$IFDEF DEBUG}
  FastMM4,
  {$ENDIF}
  ...other uses

在窗体关闭的FastMM4上产生一个MemoryManager_EventLog.txt,其中包含所有泄漏块。

这是一个示例:

    --------------------------------2019/6/19 9:49:25--------------------------------
A memory block has been leaked. The size is: 20

This block was allocated by thread 0x558, and the stack trace (return addresses) at the time was:
4075D2 [System.pas][System][@GetMem$qqri][4614]
40ABAF [System.pas][System][TObject.NewInstance$qqrv][16452]
40B3D6 [System.pas][System][@ClassCreate$qqrpvzc][17790]
40AD20 [System.pas][System][TObject.$bctr$qqrv][16516]
F3BEF6 [NdST.pas][NdST][TFinder.$bctr$qqrp14System.TObject][1011]
11157D1 [SuperNode.pas][SuperNode][TSuperNode.$bctr$qqrp14System.TObject][993]
D1D840 [Network.pas][Network][TNetwork.Create$qqrv][968]
F3A70D [NdST.pas][NdST][TNdST.$bctr$qqrp14System.TObject][177]
F3B658 [NdST.pas][NdST][TNdSTCAP.$bctr$qqrp14System.TObject][652]
10A4CCA [Print.pas][Print][TPrint.CreateCollection$qqrv][4274]
10A2773 [Print.pas][Print][TPrint.CreateItem$qqrv][3031]

The block is currently used for an object of class: TList

The allocation number is: 53883

Current memory dump of 256 bytes starting at pointer address 7EBA5360:
48 FA 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7C C4 2D 79 00 00 00 00 E0 4B BA 7E
00 00 00 00 00 00 00 00 9C CD 41 00 00 00 00 00 7C D2 00 00 D2 75 40 00 AF AB 40 00 D6 B3 40 00
1A 72 11 01 29 AD 40 00 F8 57 11 01 40 D8 D1 00 0D A7 F3 00 58 B6 F3 00 CA 4C 0A 01 73 27 0A 01
58 05 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
20 AD 40 00 B8 AB 40 00 D1 57 11 01 F4 1B 0B 01 22 4D 0A 01 87 27 0A 01 0A 48 11 01 52 6E 11 01
H  ú  I  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  |  Ä  -  y  .  .  .  .  à  K  º  ~
.  .  .  .  .  .  .  .  œ  Í  A  .  .  .  .  .  |  Ò  .  .  Ò  u  @  .  ¯  «  @  .  Ö  ³  @  .
.  r  .  .  )  ­  @  .  ø  W  .  .  @  Ø  Ñ  .  .  §  ó  .  X  ¶  ó  .  Ê  L  .  .  s  '  .  .
X  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  x  ï  ï  †
<  -  .  .  À  F  ¼  ~  .  .  .  .  .  .  .  .  .  .  .  .  ‡  .  .  y  .  .  .  .  .  Q  º  ~
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  €  Ò  .  .  Ò  u  @  .  ¯  «  @  .  Ö  ³  @  .
   ­  @  .  ¸  «  @  .  Ñ  W  .  .  ô  .  .  .  "  M  .  .  ‡  '  .  .  .  H  .  .  R  n  .  .

泄漏似乎是由TList引起的,但是我释放了每个TList。 TList.Free还不够吗?

1 个答案:

答案 0 :(得分:-2)

如果创建对象并将其引用保存到TList,则必须在释放TList之前释放它们。

for I := 0 to aList.Count-1 do
   anObjectType(aList[I]).Free;

如果要自动释放对象,请使用带有TObjectList参数集的OwnsObjectsTObjectList在销毁时释放其所有对象的内存。