使用TIDNotify进行内存泄漏,线程安全的VCL交互 [英] Memory Leak using TIDNotify , threadsafe VCL interaction

查看:98
本文介绍了使用TIDNotify进行内存泄漏,线程安全的VCL交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码用于允许来自INDY 10 tcpserver.onexecute()的线程安全VCL交互;

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;

在Onexecute函数中有

in the Onexecute function there is

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

根据MADSHI调试器,serveronexecute()中的这一行代码创建了内存泄漏.我的课程内没有免费的功能.如何使代码内存无泄漏?

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 ?

推荐答案

请确保您使用的是Indy 10的最新版本.在较旧的版本中,TIdNotify确实存在内存泄漏,但这已得到解决. 10个月前.

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.

这篇关于使用TIDNotify进行内存泄漏,线程安全的VCL交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆