我正在实现我的应用程序中的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;
我是否做了一些愚蠢的事情或者实现通知功能的代码中存在内存泄漏?
- Steve
NotificationCenter.PresentNotification(aNotification)
之后,aNotification
的值是多少? - Hugh JonesaNotification
仍然被赋值 - 太奇怪了。 - Steve Maughan