Windows 10中的内存泄漏Delphi Seattle中的TNotification?

Ste*_*han 8 delphi notifications windows-10 delphi-10-seattle

我正在我的应用程序中实现Windows 10通知.但是,下面的代码(运行正常)显然会给出1个TNotification对象和2个字符串的备忘录泄漏,但我在块的末尾释放了对象:

aNotification := NotificationCenter.CreateNotification;

//-- If not assigned then must be Win 8.1 or below
if not assigned(aNotification) then
  exit;

try
  aNotification.Title := AlignMixVersionName + ' License';
  aNotification.AlertBody := aText;

  NotificationCenter.PresentNotification(aNotification);

finally
  aNotification.Free;
end;
Run Code Online (Sandbox Code Playgroud)

我做了一些愚蠢的事情,或者在通知的实施中是否存在内存泄漏?

  • 史蒂夫

Uwe*_*abe 8

这确实是一个泄漏造成的TNotificationCenterDelegateActivated.在其创建CreateTNotification参数副本中,但从未释放过.

似乎一些负责此代码的开发人员并不熟悉非ARC环境.

  • 天真的人可能会期望Emba对他们的库进行测试以清除漏洞.它能有多难? (3认同)
  • @DavidHeffernan Naively可能会想到他们有一个简单的应用程序来测试,第一行编写的代码是`ReportMemoryLeaksOnShutdown:= true;`. (2认同)