Our apps are live on the app store. I wish to recognise crashes of out of memory that some users are getting. I understand there is no way to 100% recognise an out of memory crash. Is there any way to recognise these crashes(with a pretty large probability) by doing some logic in the applicationDidReceiveMemoryWarning? (I am not talking about finding it in xcode during development time, i am talking about code that will recognise the out of memory crash from actual users and will log something to file)
-
Use Instruments (cmd+I) do follow the allocations. – Levi Jun 09 '13 at 11:29
-
Although it's a technicality: your app being terminated due to low memory isn't really a 'crash' (although it looks like it to your user). – occulus Jun 09 '13 at 11:39
-
In general, no. But, the most likely cause of an out of memory situation is improper use of UIImage which results in too many images being held in memory at the same time. Another very likely cause is ref count loops in ViewControllers that ref other view controllers in a way that cause a loop. Trouble is, these problems often only show up in your product after it is released and it is running on end user devices. Only a very careful development process and code reviews can prevent this kind of issue. – MoDJ Mar 20 '15 at 22:18
3 Answers
While I was looking for any service or library that give me OOM tracking, I could only find this article from Facebook engineering:
https://code.facebook.com/posts/1146930688654547/reducing-fooms-in-the-facebook-ios-app/
The idea is to deduce the reason why the app needs to be launch, checking different aspects (like if the app was at background, if there is an app/OS update,...).
Discarding all the other possible reason that can force the previous app exit, you can know if the reason is a background out of memory or a foreground out of memory.
It would be nice to have a library that implements the Facebook article procedure. But nowadays I couldn't find any, probably there is some reason that make this difficult or may be impossible to add it as an sdk.
If anyone knows any service, please share it with everyone with a comment or a new answer.
Edit:
I have discovered this github (https://github.com/jflinter/JRFMemoryNoodler) with an implementation of the Facebook post procedure. I haven't tried yet, but we will deploy it in our apps to try it.

- 1,317
- 13
- 24
-
-
1@Johanisma, no we were going to deploy our apps with this library (JRFMemoryNoodler) but just before closing the build, we decided to remove it. Because when we forced the app crash (during development), we weren't sure that this tool could help us to detect the different OOM (maybe we didn't interpret correctly the crashes or it didn't work well). If you find something, share it because still have OOM. – Néstor May 13 '16 at 09:28
Look out for the applicationWillTerminate
message in your app delegate. This is called if you app is terminated by the system (due to e.g. low memory), but not if the user leaves the app in the usual way by pressing the home key. Note: if your app is in the background and memory runs out, your app gets killed without any messages being sent to it.
YMMV, especially with older versions of iOS, and it's worth researching to ensure that the above is accurate.
The images at this blog post are quite informative (although slightly dated).
For more info, see How to know whether app is terminated by user or iOS (after 10min background)
-
2will applicationWillTerminate happen every time the app is terminated because of memory (when it's in the foreground)? Also, will it get called also when the user closes the app completely (not moving it to background)? – AJ222 Jun 09 '13 at 11:48
Firstly Analyse your application by clicking on the Product at the top menu bar of your Xcode and click on Analyse section it will show you the number of leaks on in the application and can take you to the place where leaks occurred. This is how you can find the memory leak and rectify it. Secondly it above does not worked then see to the view controller where crash occurred and check whether you have left any object to release. Hope this might help you to resolve your problem.
-
2You've answered a different question to that asked. He even said in his post "I am not talking about finding it in xcode during development time". – occulus Jun 11 '13 at 15:13