I am developing an iOS app and testing its stability. There are no memory leak issues when I check it using XCode Analyze. I simulated on my iPhone 5 and iPad 2 and tried clicking buttons and flipping the UIScrollView continuously as fast as I could.
The debug log did show a “received memory warning” message several times but still no message about memory leaks. I keep doing the crazy testing and the app quits unexpectedly. I can still find the app running in background when I double click the “home” button. After I click back to the app, it can still run normally.
Therefore, here I would like to know what possible reasons would cause the app to quit unexpectedly. How might I trace the reason for the app quitting, using any tools or tactics?
PS: I am a new iOS developer and I really have no ideas about this issue. I need some help. Thank you!
There is a difference between leaked memory – which is memory you’ve allocated that you cannot give back to the system because you’ve lost the pointer to the memory and you can’t release it. And then there is poorly using memory – which is where you allocate memory. It’s not “leaked” because you can give it back, but you don’t give it back.
Consider the example of creating 100 of images.
If you create 100 image views even though they are not all visible, but you keep references to the image views, then you don’t have a leak, but you haven’t managed you memory properly.
The static analyser helps you find leaks – it doesn’t tell you where you are using memory badly.
Try running your app under Instruments with the allocations tool to see where all the memory is being created and used.