Memory leaked into this code from System.Win.TaskbarCore :
procedure TTaskbarBase.UpdateTab; var LpfIsiconic: LONGBOOL; LHandle: HWND; LFlags: Integer; begin if FTaskbarIsAvailable then begin LHandle := GetFormHandle; if not FRegistered and TaskBar.RegisterTab(LHandle) then begin TaskBar.SetTabOrder(LHandle); TaskBar.SetTabActive(LHandle); FRegistered := True; end else ETaskbarException.CreateFmt(SCouldNotRegisterTabException, [TaskBar.LastError]); ....
The last line throws an exception and then does nothing with it. The exception and the string it owns are leaking. According to FastMM.
You can register these objects as leaked if you can get their addresses. However, you cannot do this. You cannot reference this exception object.
If you just avoid this erroneous leak, and it makes sense, then you should include a fixed version of System.Win.TaskbarCore in the project. Make a copy of this file and add it to your project. Then change the code to fix the error. I assume it will look like this:
if not FRegistered then begin if TaskBar.RegisterTab(LHandle) then begin TaskBar.SetTabOrder(LHandle); TaskBar.SetTabActive(LHandle); FRegistered := True; end else raise ETaskbarException.CreateFmt(SCouldNotRegisterTabException, [TaskBar.LastError]); end;
Obviously, this needs to be reported to Embarcadero. I suggest you submit a bug report.
Another way is to try to avoid executing the dummy string altogether. I believe that if you remove this line from your .dfm file, you should avoid the dummy line and therefore avoid the leak:
Visible = True
Just delete this line, it seems to be a trigger.
Please note that I did this by reducing the project to its bare bones. To reproduce the problem, this is the minimum dfm file:
object Form1: TMainForm Visible = True object Taskbar1: TTaskbar end end
And with this dfm file there is no leak:
object Form1: TMainForm object Taskbar1: TTaskbar end end
Having reduced the project to the minimum minimum, I was able to find a trigger. I cannot stress how valuable this method of minimizing reproduction is.
Thanks to Remy for finding a quality control report for this error: QC # 128865