Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory Leak in Windows 10 TNotification in Delphi Seattle?

I'm implementing Windows 10 Notification in my application. However, the code below (which runs fine) apparently give a memo leak of 1 TNotification object and 2 strings, yet I free the object at the end of the block:

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;

Am I doing something stupid or is there a memory leak in the implementation of Notifications?

  • Steve
like image 587
Steve Maughan Avatar asked Mar 30 '16 13:03

Steve Maughan


1 Answers

It is indeed a leak caused by TNotificationCenterDelegateActivated. In its Create a copy of the TNotification parameter is created, but never freed.

Seems like some developers responsible for this code are not that proficient with non-ARC environments.

like image 93
Uwe Raabe Avatar answered Nov 16 '22 01:11

Uwe Raabe