Wednesday, May 23, 2018

Keyboard Extension Memory Leak?

Leave a Comment

I am building a custom keyboard extension (iOS 9+) and have found a more than annoying memory leak.

Just from using the template provided by Apple, there appears to be a nasty memory leak derived from an NSMutableDictionary cycle.

When leaving an application (in this test case the Messages app) then returning, this leak occurs. Typically 25 leaked items (seen in the photos of Xcode's Instruments7 below)

enter image description here

enter image description here

I have literally done nothing to the template but receive this leak. Does anyone have any suggestions on how to fix this?...

EDIT: Because Xcode tends to exaggerate (handle) memory usages differently than any physical device (my case iPhone 6s iOS 11.2), I'm not entirely sure this will even have any impact to the performance / run-life of my keyboard. From testing I did not find any issues. Going back and forth to and from Safari or Messages did not crash or switch back to the default keyboard. Nevertheless... memory leak... not good.

1 Answers

Answers 1

I sometimes find sporadic leaks that Xcode Instruments flags as such, but I cannot do anything about it, because the problem is in Apple's code, which is apparently your case. The only thing you can do is to file a bug report and go on with your project, in particular if the leak is sporadic, and is only a question of a few bytes, and does not build up in time. In summary, if these conditions apply, I wouldn't worry too much about it.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment