内存泄漏使用TIDNotify,线程安全的VCL交互

时间:2012-11-21 22:01:52

标签: delphi memory memory-leaks indy

以下代码用于允许来自INDY 10的线程安全VCL交互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;
在Onexecute函数中有

procedure TForm1.IdTCPServerExecute(AContext: TIdContext);
begin
    ....
    TVCLUpdateNotify.UpdateNavigationWindow(....)
    ....
 end;

根据MADSHI调试器,serveronexecute()中的这行代码正在创建内存泄漏。我班里没有免费的功能。如何使代码内存无泄漏?

1 个答案:

答案 0 :(得分:2)

确保您使用的是Indy 10的最新版本。在旧版本中,TIdNotify确实有内存泄漏,但是在10个月前修复了。