Delphi 为什么Indy 10报告内存泄漏?
我在Indy 10.5.7中有这个漏洞(在Delphi 7中) 5-12字节:TIdThreadSafeInteger x 1Delphi 为什么Indy 10报告内存泄漏?,delphi,Delphi,我在Indy 10.5.7中有这个漏洞(在Delphi 7中) 5-12字节:TIdThreadSafeInteger x 1 21-36字节:TIdCriticalSection x 2 我用印地是这样的: function getWeb(a,b:Integer):Integer; var url: string; H: TIdHttp; SS: TStringStream; begin url := 'http://blabla'; H := TIdHttp.Cre
21-36字节:TIdCriticalSection x 2
我用印地是这样的:
function getWeb(a,b:Integer):Integer;
var url: string;
H: TIdHttp;
SS: TStringStream;
begin
url := 'http://blabla';
H := TIdHttp.Create(nil);
try
SS := TStringStream.Create('');
try
H.Get(url, SS);
Result := StrToInt(SS.DataString);
FINALLY
SS.Free;
END;
finally H.Free;
end;
泄漏本身并不困扰我,因为应用程序正在关闭。每次关闭应用程序时,我都会看到一条错误消息,这让我的甜瓜爆炸
为什么会出现这种泄漏
我查看了印地城的网站,但几乎没有什么意义。无论如何,看起来这个错误无法修复:Indy的最新版本无法用Delphi7编译。唯一的解决办法可能是Indy 9。
更新:看起来网站上所谓的v10.203实际上是v10.2.3。这是FastMM内存管理器出现的问题,已经存在一段时间了,修复程序中有很多可用信息。我在Delphi 2010中使用的解决方案是:
{$IFNDEF DOTNET}
{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK}
function IndyRegisterExpectedMemoryLeak(AAddress: Pointer): Boolean;
{$IFDEF USEINLINE}inline;{$ENDIF}
begin
// ===== My modification begins =====================
Result := FastMM4.RegisterExpectedMemoryLeak(AAddress);
Exit;
// ===== My modification ends =====================
希望这有帮助。这是FastMM内存管理器出现的一个问题,已经存在了一段时间,有很多关于修复的信息。我在Delphi 2010中使用的解决方案是:
{$IFNDEF DOTNET}
{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK}
function IndyRegisterExpectedMemoryLeak(AAddress: Pointer): Boolean;
{$IFDEF USEINLINE}inline;{$ENDIF}
begin
// ===== My modification begins =====================
Result := FastMM4.RegisterExpectedMemoryLeak(AAddress);
Exit;
// ===== My modification ends =====================
希望这有帮助。有一个IdStack验证文件,它不通过清理功能 打开文件IdStack.pas 在文件末尾,查找以下内容:
{$ IFNDEF DOTNET}
{$ IFDEF} REGISTER_EXPECTED_MEMORY_LEAK
IndyRegisterExpectedMemoryLeak (GStackCriticalSection);
{$ ENDIF}
{$ ENDIF}
finalization
// Dont Free. If shutdown is from another Init section, it can cause GPF When stack
// Tries to access it. App will kill it off anyways, so just let it leak
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
// THIS LINE AND INCLUDE A COMMENT LINE DOWN
if GStackCriticalSection <> nil then FreeAndNil (GStackCriticalSection);
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{$ IFDEF} FREE_ON_FINAL
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
// FreeAndNil (GStackCriticalSection); // DISABLE THIS LINE
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{$ ENDIF}
end.
{$IFNDEF DOTNET}
{$IFDEF}寄存器\预期\内存\泄漏
IndyRegisterExpectedMemoryLeak(GSTACK临界段);
{$ENDIF}
{$ENDIF}
定稿
//不要免费。若关闭是从另一个Init段开始的,则在堆栈运行时可能会导致GPF
//试图访问它。这个应用程序无论如何都会杀死它,所以就让它泄漏吧
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//这一行并包含一个注释行
如果GStackCriticalSection为零,则为FreeAndNil(GStackCriticalSection);
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{$IFDEF}期末考试免费
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//FreeAndNil(GStackCriticalSection);//禁用此行
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{$ENDIF}
结束。
我使用的是Indy的10.515版本,您可以在找到此版本供下载。有一个IdStack验证文件,它不通过清理功能 打开文件IdStack.pas 在文件末尾,查找以下内容:
{$ IFNDEF DOTNET}
{$ IFDEF} REGISTER_EXPECTED_MEMORY_LEAK
IndyRegisterExpectedMemoryLeak (GStackCriticalSection);
{$ ENDIF}
{$ ENDIF}
finalization
// Dont Free. If shutdown is from another Init section, it can cause GPF When stack
// Tries to access it. App will kill it off anyways, so just let it leak
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
// THIS LINE AND INCLUDE A COMMENT LINE DOWN
if GStackCriticalSection <> nil then FreeAndNil (GStackCriticalSection);
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{$ IFDEF} FREE_ON_FINAL
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
// FreeAndNil (GStackCriticalSection); // DISABLE THIS LINE
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{$ ENDIF}
end.
{$IFNDEF DOTNET}
{$IFDEF}寄存器\预期\内存\泄漏
IndyRegisterExpectedMemoryLeak(GSTACK临界段);
{$ENDIF}
{$ENDIF}
定稿
//不要免费。若关闭是从另一个Init段开始的,则在堆栈运行时可能会导致GPF
//试图访问它。这个应用程序无论如何都会杀死它,所以就让它泄漏吧
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//这一行并包含一个注释行
如果GStackCriticalSection为零,则为FreeAndNil(GStackCriticalSection);
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{$IFDEF}期末考试免费
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//FreeAndNil(GStackCriticalSection);//禁用此行
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{$ENDIF}
结束。
我使用的是Indy的10.515版本,您可以在找到该版本以下载,以删除主DPR中包含此命令的其他消息
Application.terminate;
if GThreadCount <> Nil then GThreadCount.Free;
Application.terminate;
如果GThreadCount为Nil,则GThreadCount.Free;
添加IdThread使用
甚至更多 要删除其他消息,请在主DPR中包含此命令
Application.terminate;
if GThreadCount <> Nil then GThreadCount.Free;
Application.terminate;
如果GThreadCount为Nil,则GThreadCount.Free;
添加IdThread使用
甚至更多 那是一年半前的事了。使用Delphi版本附带的Indy版本的用户正在使用过时的版本,应该升级。嗨,Rob。我正在使用IdAbout.ShowDlg;这表明我的印第河是10.5.7。有比这更新的版本吗?嗨,布莱恩。我的Delphi 7显示IndyRegisterExpectedMemoryLeak没有编译(没有蓝点),但是初始化和终结部分有点。@目前的Indy版本是10.5.8(见IdVers.inc)@mjn-他们只有v10.5.7-那是一年半以前的版本。使用Delphi版本附带的Indy版本的用户正在使用过时的版本,应该升级。嗨,Rob。我正在使用IdAbout.ShowDlg;这表明我的印第河是10.5.7。有比这更新的版本吗?嗨,布莱恩。我的Delphi 7显示IndyRegisterExpectedMemoryLeak没有编译(没有蓝点),但是初始化和终结部分确实有点。@当前的Indy版本是10.5.8(见IdVers.inc)@mjn-它们只有v10.5.7-请不要在这里的帖子中使用签名、标语或其他类似信息。你发布的每一篇文章的右下角都有你的名字,你的个人资料可以告诉人们你是谁,你的爱好是什么,以及你想让他们知道的关于你的任何事情。谢谢。请不要在这里的帖子中使用签名、标语或其他类似信息。你发布的每一篇文章的右下角都有你的名字,你的个人资料可以告诉人们你是谁,你的爱好是什么,以及你想让他们知道的关于你的任何事情。谢谢