I've got a notification service extension which uses quite a lot of memory when it runs.
Its using UIGraphicsImageRenderer:image() to create an image based on the push payload, and that that is a very memory hungry function.
When the extension receives a push it uses less than the 25MB memory limit for extensions and its successful and runs to completion. However the next push that gets receives crashes due to memory not being freed (it doesn't matter if several minutes elapses between pushes).
After its crashed its successful once more (the action of it crashing must obviously be freeing up the memory, so after a crash there's enough memory to run again, but then the next push after that will crash and so on and so on).
I've run the extension interactively in Xcode's debugger to observe this behavior, but it also happens when running independently of Xcode (and thus lifetimes of things aren't being kept alive by the Xcode debugger).
As my extension has no control over the creation/destruction lifecycle of UNNotificationServiceExtension, is there anything that can be done to force the OS/UNNotificationServiceExtension to fully unload and release all its resources?