看来,设置ReportMemoryLeaksOnShutdown := true
不会对用Delphi 10.2东东创建的程序有任何影响(我在Windows和Linux程序中试过)。即使有明显的内存泄漏,也没有任何报道。“ReportMemoryLeaksOnShutdown”不能在Delphi 10.2东京工作?
有人可以证实这一点吗?有没有其他方法来检查Linux程序中的内存泄漏?在Windows上,我可以使用madExcept。
------------------编辑2 ------------------
在Delphi 10.2 ReportMemoryLeaksOnShutdown := true
似乎只适用于未标记为控制台应用程序的程序。一旦我注释掉行{$APPTYPE CONSOLE}
我收到所需的错误信息(当我在Windows上运行该程序)。
------------------编辑1 ------------------
这是请求的示例:
program WeakRefTest;
{$APPTYPE CONSOLE}
{$R *.res}
uses
SysUtils;
type
TParent = class;
TChild = class
private
{$IFDEF AUTOREFCOUNT} [Weak] {$ENDIF}
Parent: TParent;
public
constructor Create (const Parent: TParent);
destructor Destroy; override;
end; { TChild }
TParent = class
private
Child : TChild;
public
constructor Create;
destructor Destroy; override;
end; { TParent }
constructor TChild.Create(const Parent: TParent);
begin
inherited Create;
WriteLn ('TChild.Create');
Self.Parent := Parent;
end;
destructor TChild.Destroy;
begin
WriteLn ('TChild.Destroy');
inherited;
end;
constructor TParent.Create;
begin
inherited;
WriteLn ('TParent.Create');
Child := TChild.Create (Self);
end;
destructor TParent.Destroy;
begin
WriteLn ('TParent.Destroy');
inherited;
end;
procedure SubRoutine;
var
Parent : TParent;
begin
Parent := TParent.Create;
WriteLn ('"SubRoutine" exit');
end; { SubRoutine }
begin { WeakRefTest }
ReportMemoryLeaksOnShutdown := true;
try
SubRoutine;
WriteLn ('"WeakRefTest" done');
except
on E: Exception do
WriteLn (E.ClassName, ': ', E.Message);
end;
end.
要强制在Linux上注释掉在的TChild
声明的[Weak]
属性就行了内存泄漏。当编译Windows时,会有内存泄漏,因为ARC不受支持。
当我编译并采用Delphi XE出现一则消息,有内存泄漏运行代码:
当我编译并采用Delphi 10.2没事的Windows运行出现了。我在TChild
的声明中注释掉[Weak]
属性后,使用Linux编译器时也是如此。
提交(在Windows FMX项目)Embarcadero公司 –
我只是测试一个bug报告,它工作正常。你能举一个例子吗? – Dsm
您应该用[mcve] –