【发布时间】: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;
我是在做一些愚蠢的事情还是在通知的实现中存在内存泄漏?
- 史蒂夫
【问题讨论】:
-
aNotification在NotificationCenter.PresentNotification(aNotification)之后的值是多少? -
@HughJones
aNotification仍然在PresentNotification之后分配 - 太奇怪了。 -
我在很多个月前做过 Delphi,记得把东西设置为 nil ... aNotification := nil;
-
在 RAD Studio 的问题跟踪器中针对此内存泄漏打开了一个问题:quality.embarcadero.com/browse/RSP-17660
标签: delphi notifications windows-10 delphi-10-seattle