How to track down tricky memory leak with fastMM?

≯℡__Kan透↙ 提交于 2019-11-29 06:58:33

This memory leak was being caused by a Delphi bug, QC #67709

It was fixed by the last Delphi 2009 update, no wonder I wasn't able to fix it.

As long as the size of the memory block leaked does not grow the longer/more your program is used, then it isn't a concern. If you have long lived objects that are only freed when you terminate the application it is the same as if you leaked them - all memory is reclaimed on termination (Unless of course they have handles resources beyond memory).

The memory leaks you want to be concerned with are the ones that accumulate over time or usage. If it is 20 bytes everytime then don't sweat it.

I don't know if there are any leaks in D2009 VCL, so presuming leak is in your code, first I would check following:

  • is there any array or list (because of @DynArraySetLength) created in that form that is not released when you dispose form.
  • is there any function that creates and returns some object that should be freed by outside caller, and if you have that kind of function check if caller frees that object.
  • if this does not reveal leak, then you should check if each object that you create in your form code, gets destroyed when you destroy the form.

The last time I had a puzzling leak along these lines I looked over the raw memory of the offending object--and saw text that showed me what sort of data it was. When it says it doesn't know what sort of object it is that likely means it isn't an object in the first place--so look at dynamically allocated things, including strings.

IIRC VCL had a few very small leaks like this that you can ignore without much worry. This might be one of them!? Hope somebody clarifies this point.

I would say you have something happening in your Form OnCreate event handler that is growing a DynArray.
And that DynArray is not released at the end.
But without seeing the code and actually debugging it with FastMM, it's close to impossible to guess what's really happening.

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