以下代码用于允许来自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;
procedure TForm1.IdTCPServerExecute(AContext: TIdContext);
begin
....
TVCLUpdateNotify.UpdateNavigationWindow(....)
....
end;
根据MADSHI调试器,serveronexecute()中的这行代码正在创建内存泄漏。我班里没有免费的功能。如何使代码内存无泄漏?
答案 0 :(得分:2)
确保您使用的是Indy 10的最新版本。在旧版本中,TIdNotify
确实有内存泄漏,但是在10个月前修复了。