用的xe,自带的ReportMemoryLeaksOnShutdown还蛮好用,能显示没释放的对象名
但是我程序里有dll,都在uses第一句里加上了sharemem,因为这句自带的内存泄漏检测都没效果了

解决方案 »

  1.   

    用了网上的checkmem好像不好用,创建个窗体,运行,关闭,也有内存泄漏,估计是不支持xe
      

  2.   


      ReportMemoryLeaksOnShutdown := DebugHook<>0;//加上这句
      Application.Initialize;Delphi 2010有自带的
      

  3.   

    你的程序不见得就有泄露 啊,在delphi 2010 中 F9 ,程序退出的时候只有泄露了才会提示program Project1;uses
      Forms,
      Unit2 in 'Unit2.pas' {Form2};{$R *.res}begin
      ReportMemoryLeaksOnShutdown := DebugHook<>0;
      Application.Initialize;
      Application.MainFormOnTaskbar := True;
      Application.CreateForm(TForm2, Form2);
      Application.Run;
    end.uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm2 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form2: TForm2;
      s:TMemoryStream;implementation{$R *.dfm}procedure TForm2.FormCreate(Sender: TObject);
    begin
      s:=TMemoryStream.Create;//这里的s程序退出的时候没有释放
      s.LoadFromFile('G:\notepad.exe');
    end;end.
      

  4.   

    现在情况是程序有几个dll,函数参数都是string,所以在uses第一句都有sharemem
    就因为这个所以delphi自带的内存检测无效了(我在窗体create里建立了对象没释放测试过)EurekaLog也下载了新版,也点了“启用”,但是貌似也没效果,以前用着正常的