问题
the following code is used to allow threadsafe VCL interaction from INDY 10 tcpserver.onexecute();
/// a function to write information into a TBitmap
TVclNavigationImage= procedure( ll, ur, ll_v , ur_v : TPoint ) of object;
TVCLUpdateNotify = class(TIdNotify)
protected
f_ll, f_ur, f_ll_v , f_ur_v : TPoint;
FProc: TVclNavigationImage;
procedure DoNotify; override;
public
constructor Create(ll, ur, ll_v , ur_v : TPoint; aProc:TVclNavigationImage); reintroduce;
class procedure UpdateNavigationWindow(ll, ur, ll_v , ur_v : TPoint ; aProc: TVclNavigationImage);
end;
class procedure TVCLUpdateNotify.UpdateNavigationWindow(ll, ur, ll_v , ur_v : TPoint ; aProc: TVclNavigationImage);
begin
with Create(ll, ur, ll_v , ur_v, aProc) do
begin
Notify;
end;
end;
in the Onexecute function there is
procedure TForm1.IdTCPServerExecute(AContext: TIdContext);
begin
....
TVCLUpdateNotify.UpdateNavigationWindow(....)
....
end;
According to MADSHI debugger this line of code in the serveronexecute() is creating a memory leak. There is no free function inside my class. How to make that code memory leak free ?
回答1:
Make sure you are using an up-to-date version of Indy 10. In older versions, TIdNotify
did have a memory leak, but that was fixed 10 months ago.
来源:https://stackoverflow.com/questions/13502748/memory-leak-using-tidnotify-threadsafe-vcl-interaction