【发布时间】:2012-11-21 22:01:51
【问题描述】:
以下代码用于允许来自 INDY 10 tcpserver.onexecute() 的线程安全 VCL 交互;
/// 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() 中的这行代码正在造成内存泄漏。我的班级里没有免费的功能。如何使该代码无内存泄漏?
【问题讨论】:
-
为了大家的眼睛,请修正你的问题的标题!
-
看起来
TIdNotify是异步的。这意味着释放它是框架的工作。在进行了几次网络搜索之后,似乎确实有一些 Indy 版本存在导致内存泄漏的TIdNotify错误。但我对此不太确定,对印地一无所知。无论如何,也许您使用的是旧版本的 Indy,它只是泄漏。例如:indy.codeplex.com/workitem/22030
标签: delphi memory memory-leaks indy