Start a new topic
Solved

iOS Swift Memory Leak

In testing the Swift implementation of the Native SDK Examples for iOS there seems to be a memory leak in the Swift examples.


As a baseline here is the memory graph from loading the Objective C examples when moving back and forth from the Simple Image Tracking option and the menu:


image


Here you can see the memory usage goes from ~45MB when in the menu to ~180MB when in the Simple Tracking scene which is good.


If we compare this to the Swift examples using the same scene the graph looks quite different:


image



Here the menu starts at ~25MB then when clicking the Simple Tracking scene we reach the expected ~180MB however this time returning to the menu leaves us with ~90MB used. If we do this one more time the menu will sit at ~250MB used. I tried to do the back and forth a third time but the app crashed with an out of memory exception. To me this indicates there is a big memory leak in the Swift examples.



Is there a know fix for this? I need to use the Swift implementation but with this bug it is pretty much impossible to ship if the app crashes after the third time trying to launch the AR view.


Hi Mitch,

Just a few days ago we noticed the leak as well. It will be fixed in our next update. In the meantime you can switch from `viewDidDisappear` to `viewWillDisappear` in the example/your own app. This should solve the problem temporarily.


Best regards,
Andreas Schacherbauer

Great, thanks for the quick response.

Moving to viewWillDisappear seems to have done the trick for now.

This is with SDK 8.2

Login or Signup to post a comment