delphi - Delphi FastMM4 how read MemoryManager_EventLog.txt?
问题描述
I have added FastMM4 to my project for detect a memory leak
program MyProg;
uses
{$IFDEF DEBUG}
FastMM4,
{$ENDIF}
...other uses
on form close FastMM4 produce a MemoryManager_EventLog.txt
, with all leak block.
This is an example:
--------------------------------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 . .
The leak seem to be caused by TList, but I free every TList. Is TList.Free
not sufficient?
解决方案
If you create objects and save their references to TList, it is essential that you free them before the TList is freed.
for I := 0 to aList.Count-1 do
anObjectType(aList[I]).Free;
If you want your objects to be freed automatically, use TObjectList
with OwnsObjects
parameter set. TObjectList
frees the memory of all its objects when it is destroyed.
推荐阅读
- ruby-on-rails - rails ujs调用类的子集
- python-3.x - 回调函数在 scipy.optimize.minimize 类中引发错误
- python - 有没有办法用 numpy 为数组中 n 行的所有组合计算一些东西(简单的情况是所有对,即 n = 2)
- angular - 取消之前的 http 请求并使用 async 运行新的
- node.js - 如何使用 Mongoose 渲染我的数据库的内容?
- java - 单击 Java 更改边框颜色
- python - 两个分类变量之间的比较
- joomla - Joomla!3.8.13 - 文章管理器添加图片不起作用(错误的 url)
- arrays - 如何在 Swift 中打印结构的某些元素?
- java - 如何在java中使用ecc加密图像