2012-04-09 67 views
3

我正在研究一个软件,所以我刚开始在我的项目中使用FastMM4(真实的)。FastMM4,如何读取日志文件?

我在网上找到关于如何在FastMM4中获得line number的信息,我得到了行号,但是我可以弄清楚日志中其他信息的含义是什么?

我有这个日志文件

This block was allocated by thread 0x15F8, and the stack trace (return addresses) at  the time was: 
402E86 [system.pas][System][[email protected]][2648] 
403A3B [system.pas][System][System.TObject.NewInstance][8824] 
403DAA [system.pas][System][[email protected]][9489] 
403A70 [system.pas][System][System.TObject.Create][8839] 
46A257 [u_home.pas][u_home][u_home.TForm1.SpeedButton1Click][80] {<-memory leak is here, but what are the Other detections?} 
443AAC [Controls.pas][Controls][Controls.TControl.Click][5226] 
46958B [Buttons.pas][Buttons][Buttons.TSpeedButton.Click][1211] 
46956B [Buttons.pas][Buttons][Buttons.TSpeedButton.MouseUp][1204] 
443FB2 [Controls.pas][Controls][Controls.TControl.DoMouseUp][5352] 
441BA0 [Controls.pas][Controls][Controls.TControl.SetMouseCapture][4379] 
444042 [Controls.pas][Controls][Controls.TControl.WMLButtonUp][5364] 

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

The allocation number is: 440 
在此

leak

46A257 [u_home.pas][u_home][u_home.TForm1.SpeedButton1Click][80] {<-memory leak is here, but what are the Other detections?} 

我的代码

procedure TForm1.SpeedButton1Click(Sender: TObject); 
    var 
    str : TStringList; 
    begin 
    str := TStringList.Create; {<--im not freeing the, so leak} 

    end; 

enter image description here

这里是call stack enter image description here

我搜索网上的,但我不知道什么是其他检测...

402E86 [system.pas][System][[email protected]][2648] 
403A3B [system.pas][System][System.TObject.NewInstance][8824] 
403DAA [system.pas][System][[email protected]][9489] 
403A70 [system.pas][System][System.TObject.Create][8839] 

{Other then this} 
46A257 [u_home.pas][u_home][u_home.TForm1.SpeedButton1Click][80] {<-memory leak is here, but what are the Other detections?} 
{Other then this} 

443AAC [Controls.pas][Controls][Controls.TControl.Click][5226] 
46958B [Buttons.pas][Buttons][Buttons.TSpeedButton.Click][1211] 
46956B [Buttons.pas][Buttons][Buttons.TSpeedButton.MouseUp][1204] 
443FB2 [Controls.pas][Controls][Controls.TControl.DoMouseUp][5352] 
441BA0 [Controls.pas][Controls][Controls.TControl.SetMouseCapture][4379] 
444042 [Controls.pas][Controls][Controls.TControl.WMLButtonUp][5364] 

使用delphi 2006

我已经打开并试图将IM同样在delphi 6, delph 7

检查 我发现这与fastMM $ detectiong和已经在delphi中的一些泄漏的注册有关。 How to track down tricky memory leak with fastMM? 和这注册泄漏,但他们是错误? Using FastMM4, how to register leaked string?

而且FastMM4, Delphi6, Leak of TApplication?

OR are they just the steps leading to the memory leak?

回答

5

你在日志中有什么是导致该泄漏的内存分配调用堆栈。

你可以看到它在你的问题中的调用堆栈中有多有用。试想一下,你只用了顶线,这导致泄漏

402E86 [system.pas][System][[email protected]][2648] 

,关于自己的信息几乎是无用的,因为所有的堆分配都要经过GetMem呼叫。这是调用堆栈,它指向导致呼叫GetMem的事件。这就是查明造成泄漏的原因。

+0

+ 1,OK,总之他们是'steps'它们会导致内存泄漏? – PresleyDias 2012-04-09 10:51:17

+0

有没有办法只显示/显示单元名称/类名/行号,就像这个'46A257 [u_home.pas] [u_home] [u_home.TForm1.SpeedButton1Click] [80]' – PresleyDias 2012-04-09 10:53:32

+0

我不知道我不明白最后一个问题。 – 2012-04-09 11:07:20

4

FastMM没有办法猜测代码背后的意图,并确定哪个指令导致内存分配应该有相应的指令释放它。

请记住,FastMM只保留执行代码期间所有内存分配的记录。
它不知道为什么,如何或在哪里发生泄漏,只是在您的应用程序关闭并且所有内容都应该清理时没有释放此特定分配。

所以当泄漏报​​告时,它确实是一个显示的分配。
FastMM不知道您的应用程序,并且只能显示导致您分配内存的代码(通常是gazillion GetMem调用之一)中的此特定点的整个调用链。
有意义的信息可以通过爬梯子找到,直到找到需要一些内存的更高级别的指令,比如TButton.Create并查看该特定的Button是否被释放(泄漏其所有内容),或者像是TMyBadButton.Create哪个创建一些AltBitmap,但永远不会释放它。
在一种情况下,应用程序代码中的泄漏没有释放它,但在另一种情况下,它在TMyBadButton组件代码中。

更新: 您可能会发现有用的这个老CodeRage会议Memory Leaks for Dummies

+0

+ 1,内存泄漏的傻瓜...很好的信息, – PresleyDias 2012-04-09 18:20:51

+0

有没有人有CodeRage内存泄漏的傻瓜镜像? @francois链接不存在 – sybond 2012-10-10 09:22:14

+0

@sybond,我刚刚尝试链接,并得到了zip文件... – 2012-10-17 05:19:40