Search code examples
iosiphonexcodememory-leaksinstruments

Device gets restarted when trying to run App


I have a iPhone 5 device that i use to test the app i'm trying to run. It has enough storage and runs other apps as expected.

I'm trying to run my app through xCode with this device but before it will start the app it restarts the iPhone and is not able to enter the app.

I think it is a memory issue that is causing the device to restart but i'm not sure where to look as i have tried both Instruments on the Mac as well as checking the log for the device, but because the app restarts every time on start up it does not record the data.

Is there any other app or another method i could use to see if there are memory leaks.


Solution

  • I've recently come across this error again with xCode. After taking some time investigating and debugging using instruments, it showed there were a few memory leaks taking place during the start of the app.

    In our codebase there were a few places where there were objects that were not assigned weak/ unowned, causing the memory leaks for those objects being used on start up.

    After assigning weak or unowned to those objects, it solved the memory leak issues I was experiencing in the app.

    For reference I used this article to understand the problem better: https://medium.com/flawless-app-stories/all-about-memory-leaks-in-ios-cdd450d0cc34

    Medium Article on the differences and how to use Weak or Unowned on a object: https://medium.com/hackernoon/swift-weak-vs-unowned-by-examples-ffcc7c25ecc8#:~:text=The%20main%20difference%20between%20weak,will%20crash%20the%20whole%20program.