![](/img/trans.png)
[英]Delphi FastMM4 how read MemoryManager_EventLog.txt?
[英]FastMM4, how to read the log file?
我正在開發一個軟件,所以我剛剛開始在我的項目中使用 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][System.@GetMem][2648]
403A3B [system.pas][System][System.TObject.NewInstance][8824]
403DAA [system.pas][System][System.@ClassCreate][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;
這是call stack
我在.net 上搜索但我不知道其他檢測結果是什么...
402E86 [system.pas][System][System.@GetMem][2648]
403A3B [system.pas][System][System.TObject.NewInstance][8824]
403DAA [system.pas][System][System.@ClassCreate][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
我已經在delphi 6, delph 7
中打開並嘗試過相同的操作
檢查我發現這與 fastMM$ 檢測和一些泄漏的注冊有關,這些泄漏已經在 delphi 中。 如何使用 fastMM 追蹤棘手的 memory 泄漏? 這是為了注冊泄漏,但它們是錯誤嗎? 使用FastMM4,如何注冊泄露的字符串?
還有FastMM4、Delphi6、TApplication 泄漏?
或者are they just the steps leading to the memory leak?
您在日志中看到的是導致 memory 分配泄漏的調用堆棧。
您可以在問題的調用堆棧中看到它的用處。 想象一下,您只有頂行,即導致泄漏的電話
402E86 [system.pas][System][System.@GetMem][2648]
該信息本身幾乎沒有用,因為所有堆分配 go 通過GetMem
。 調用堆棧將您指向導致調用GetMem
的事件。 這就是導致泄漏的原因。
FastMM 無法猜測代碼背后的意圖並確定導致 memory 分配的指令應該有相應的指令來釋放它。
請記住,FastMM 僅記錄在執行代碼期間完成的所有 memory 分配。
它不知道泄漏發生的原因、方式或位置,只是當您的應用程序關閉時您沒有釋放這個特定的分配,一切都應該是干凈的。
因此,當報告泄漏時,實際上顯示的是分配。
FastMM 不了解您的應用程序,只能顯示通向您分配 memory 的代碼中這一特定點的整個調用鏈(通常是無數 GetMem 調用之一)。
有意義的信息可以通過爬梯子找到,直到找到需要一些 memory 的更高級別的指令,例如TButton.Create
並查看該特定按鈕是否被釋放(泄漏其所有內容),或者像TMyBadButton.Create
創建一些 AltBitmap 但從不釋放它。
在一種情況下,泄漏是在應用程序代碼中創建一個按鈕而不釋放它,在另一種情況下,它是在TMyBadButton
組件代碼中。
更新:您可能會發現這個舊的 CodeRage session Memory Leaks for Dummies很有用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.