Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用;报告MemoryLeaksonShutdown“;不在Delphi 10.2东京工作?_Delphi_Delphi 10.2 Tokyo - Fatal编程技术网

&引用;报告MemoryLeaksonShutdown“;不在Delphi 10.2东京工作?

&引用;报告MemoryLeaksonShutdown“;不在Delphi 10.2东京工作?,delphi,delphi-10.2-tokyo,Delphi,Delphi 10.2 Tokyo,似乎设置ReportMemoryLeaksOnShutdown:=true在使用Delphi 10.2 Tokyo创建的程序中没有任何效果(我在Windows和Linux程序中尝试过)。即使存在明显的内存泄漏,也不会报告任何内容 有人能证实这一点吗?有没有其他方法可以检查Linux程序中的内存泄漏?在Windows上,我可以使用它 ------------------编辑2------------------ 在Delphi 10.2ReportMemoryLeaksOnShutdown:=tr

似乎设置
ReportMemoryLeaksOnShutdown:=true
在使用Delphi 10.2 Tokyo创建的程序中没有任何效果(我在Windows和Linux程序中尝试过)。即使存在明显的内存泄漏,也不会报告任何内容

有人能证实这一点吗?有没有其他方法可以检查Linux程序中的内存泄漏?在Windows上,我可以使用它

------------------编辑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编译并运行代码时,会出现一条消息,表明内存泄漏:


当我使用Delphi10.2为Windows编译和运行时,什么都没有显示。在注释掉
TChild

声明中的
[Weak]
属性后使用Linux编译器时也是如此。如果从cmd窗口运行控制台应用程序,它将显示有关内存泄漏的相应消息。 内存泄漏报告的行为已更改,窗口应用程序将显示MessageBox,而控制台应用程序将在控制台中获取消息

在Delphi XE2中,ScanForMemoryLeaks过程中只有一个MessageBoxA。 在Delphi10.2中,有一个自定义过程ShowMessage(AMessage,ATitle:_PAnsiChr);它可以交替调用WriteConsoleFile或MessageBoxA。 所以它是被设计的,而不是bug(IMHO)


比较讨论:

如果从cmd窗口运行控制台应用程序,它将显示有关内存泄漏的相应消息。 内存泄漏报告的行为已更改,窗口应用程序将显示MessageBox,而控制台应用程序将在控制台中获取消息

在Delphi XE2中,ScanForMemoryLeaks过程中只有一个MessageBoxA。 在Delphi10.2中,有一个自定义过程ShowMessage(AMessage,ATitle:_PAnsiChr);它可以交替调用WriteConsoleFile或MessageBoxA。 所以它是被设计的,而不是bug(IMHO)


比较讨论:

向刚测试过(在Windows FMX项目上)的EmbarcaderoI提交一份bug报告,它工作正常。你能提供一个例子吗?你应该用一个简单的例子来演示,然后提交一个bug报告。@Craig Young:给你:
var p:Pointer;开始报告MemoryLeaksonShutdown:=true;GetMem(p,100);结束。
向刚测试过的EmbarcaderoI提交一份bug报告(在Windows FMX项目上),它工作正常。你能提供一个例子吗?你应该用一个简单的例子来演示,然后提交一个bug报告。@Craig Young:给你:
var p:Pointer;开始报告MemoryLeaksonShutdown:=true;GetMem(p,100);结束。
感谢您澄清这一点。从我的观点来看,这还没有被正确地考虑过,但现在我知道是什么导致了这种行为,我可以一直使用或使用所描述的
ExitProcessProc
。感谢您澄清这一点。从我的观点来看,这还没有被正确地考虑过,但是现在我知道是什么导致了这种行为,我可以一直使用或使用所描述的
ExitProcessProc