2012-04-09 68 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