【问题标题】:Memory Leak in Windows 10 TNotification in Delphi Seattle?Delphi Seattle 的 Windows 10 TNotification 内存泄漏?
【发布时间】:2016-07-18 13:31:37
【问题描述】:

我正在我的应用程序中实现 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;

我是在做一些愚蠢的事情还是在通知的实现中存在内存泄漏?

  • 史蒂夫

【问题讨论】:

  • aNotificationNotificationCenter.PresentNotification(aNotification) 之后的值是多少?
  • @HughJones aNotification 仍然在 PresentNotification 之后分配 - 太奇怪了。
  • 我在很多个月前做过 Delphi,记得把东西设置为 nil ... aNotification := nil;
  • 在 RAD Studio 的问题跟踪器中针对此内存泄漏打开了一个问题:quality.embarcadero.com/browse/RSP-17660

标签: delphi notifications windows-10 delphi-10-seattle


【解决方案1】:

确实是TNotificationCenterDelegateActivated造成的泄露。在其Create 中创建了TNotification 参数的副本,但从未释放。

似乎一些负责此代码的开发人员对非 ARC 环境并不那么精通。

【讨论】:

  • 感谢您的确认。
  • 在 Emba 进行 QC 会很棒。
  • 天真地人们可能会期望 Emba 对其库进行测试以清除泄漏。有多难?
  • @DavidHeffernan 天真地人们可能会期望他们有一个简单的应用程序来测试,并且第一行书面代码是ReportMemoryLeaksOnShutdown := true;
  • @Hugh 不,它与垃圾收集不同
猜你喜欢
  • 2016-01-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-18
  • 1970-01-01
相关资源
最近更新 更多