FastMM4, how to read the log file?

别等时光非礼了梦想. 提交于 2019-12-12 15:01:11

问题


i'am working on an software,so i have just started using FastMM4 (for real) in my project.

i have found on the net on about how to get the line number in FastMM4,i got the line number but i can figure out what does the other information in the log means?

i have this in the log file

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

in this the leak is

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

my code

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

  end;

and here is the call stack

i searched on net but i do not know what are the other detections...

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]

im using delphi 2006

i have opened and tried the same in delphi 6, delph 7 also

checked i have found this related to fastMM$ detectiong and registration of some leaks which is already in delphi. How to track down tricky memory leak with fastMM? and this for registering the leak but are they bugs? Using FastMM4, how to register leaked string?

Also FastMM4, Delphi6, Leak of TApplication?

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


回答1:


What you have in the log there is the call stack that resulted in the memory allocation that leaked.

You can see how useful it is in the call stack in your question. Imagine that you only had the top line, the call that resulted in the leak

402E86 [system.pas][System][System.@GetMem][2648]

That information on its own is pretty much useless since all heap allocations go through GetMem. It is the call stack that points you to the events that led up to the call to GetMem. And that's what pinpoints what caused the leak.




回答2:


FastMM has no way to guess the intention behind the code and pinpoint which instruction causing a memory allocation should have a corresponding instruction to free it.

Keep in mind that FastMM only keeps a record of all memory allocation done during the execution of your code.
It does not know why, how or where a leak occurs, just that you have not freed this particular allocation at the time when your application shuts down and everything should be clean.

So when a leak is reported, it is really an allocation that is displayed.
FastMM does not know your application and can only show the whole call-chain that leads to this specific point in code where you allocate memory (usually one of a gazillion GetMem calls).
The meaningful information can be found by going up the ladder until you find the higher level instruction that needed some memory, like a TButton.Create and see if that particular Button was freed or not (leaking all its content), or like a TMyBadButton.Create which creates some AltBitmap but never frees it.
In one case the leak is in the application code creainge a button without freeing it, in the other case, it is in the TMyBadButton component code.

Update: You may find useful this old CodeRage session Memory Leaks for Dummies



来源:https://stackoverflow.com/questions/10071185/fastmm4-how-to-read-the-log-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!