为什么报告了Indy

为什么报告了Indy

本文介绍了为什么报告了Indy 10的内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



5 - 12个字节:TIdThreadSafeInteger x 1

21 - 36个字节:TIdCriticalSection x 2






我使用Indy这样:



函数getWeb(a,b:Integer):整数; $ {pre>
var url:string;
H:TIdHttp;
SS:TStringStream;
begin
url:='http:// blabla';
H:= TIdHttp.Create(nil);
try
SS:= TStringStream.Create('');
try
H.Get(url,SS);
结果:= StrToInt(SS.DataString);
FINALLY
SS.Free;
END;
finally H.Free;
结束

漏洞本身并不打扰我,因为在应用程序关机。这使得我的甜瓜爆炸是我每次关闭应用程序时看到的错误消息。



为什么会出现这种泄漏?






我已经检查了Indy网站,但几乎没有任何意义。无论如何,它看起来这个bug无法修复:最新版本的Indy不能用Delphi 7编译。唯一的解决方案可能是Indy 9.
更新:它看起来像在网站上调用v10.203是什么实际上是v10.2.3。

解决方案

这是FastMM内存管理器发生的问题,已经有一段时间了很多有关修复的信息。我在Delphi 2010中使用的解决方案是:


  1. 将以下更改下载到文件IdGlobal.pas

  2. 在库中添加路径C:\Program Files\Embarcadero\RAD Studio\7.0\source\Indy\Indy10\System(不带引号)。

更改:

  {$ IFNDEF DOTNET} 
{$ IFDEF REGISTER_EXPECTED_MEMORY_LEAK}
函数IndyRegisterExpectedMemoryLeak(AAddress:Pointer):Boolean;
{$ IFDEF USEINLINE} inline; {$ ENDIF}
begin

// =====我的修改开始============ =========

结果:= FastMM4.RegisterExpectedMemoryLeak(AAddress);
退出;


// =====我的修改结束=====================

希望这有帮助。


I have this leak in Indy 10.5.7 (under Delphi 7).

5 - 12 bytes: TIdThreadSafeInteger x 1
21 - 36 bytes: TIdCriticalSection x 2


I use Indy like this:

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;

The leak itself doesn't bother me since is on app shutdown. That makes my melon explode is the error message I see every time I shut down the app.

Why this leak appear?


I have checked the Indy web site but it barely makes sense. Anyway, it looks this bug cannot be fixed: the latest version of Indy cannot be compiled with Delphi 7. The only solution might be Indy 9.Update: it looks like what on the web site calls v10.203 is is actually v10.2.3.

解决方案

This is a problem that occurs with FastMM memory manager and has been around for a while and there is a lot of information available on fixes. The solution I use in Delphi 2010 is:

  1. Make the changes below to the file IdGlobal.pas
  2. Add the path "C:\Program Files\Embarcadero\RAD Studio\7.0\source\Indy\Indy10\System" (without quotes) to the library.

Changes:

{$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 =====================

Hope this helps.

这篇关于为什么报告了Indy 10的内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:38