Got memory pressure notification (critical) in iOS - ios

I am downloading media contents from server and app crashes after certain time by giving following error:
Got memory pressure notification (critical)
Removed all object when I get warning in didReceiveMemoryWarning function but no luck.
How can I resolve this crash? Is there any way that I can restart the view controller after freeing all memory?

Make sure you are not retaining anything in memory from all the stuff you download. There are some API calls (like imageNamed for instance) that store things into a memory cache and that will kill your app if you do too much of it too quickly.
Also crashlogs won't help. You should check memory usage in instruments to see where it's going.

Related

When will ios fire didReceiveMemoryWarning method?

When will iOS trigger the didReceiveMemoryWarning method?
I am getting a crash in my app while playing an DRM encryped video.
Check the below screenshot. I am using only 27mb of RAM and I am getting a memory warning in the console as you can see in the image and the app simply crashes. What can be the possible reason?
I tried profiling the app using allocation instrument. I checked the discard events with freed memory and ran the app. There also I am getting the memory warning message even though the app only uses ~50mb of RAM.Please check the image below.

iOS - applicationDidReceiveMemoryWarning - Why?

I'm working with a Unity project that is running on my iOS devices via Xcode, and I'm currently getting the error:
applicationDidReceiveMemoryWarning()
Every second. Yet my memory usage is around 40Mbs, which is 4% of my memory. So how am I getting a memory error? It's also the only app running. There are no other apps running in the background.
Please advise?
Thanks.
I've seen situations where allocated a lot of memory at once (or a lot of small amounts of memory quickly) will cause the app to receive memory warnings. Not sure why that's the case as you'd think it would be ok until you started using too much in total but maybe iOS doesn't like it as it could affect performance of other apps or the OS itself.

Get Notified of Low Memory Crashes

I am trying to find a way to capture low memory crashes.
Most crash reporting tools, for example Crashlytics, do not capture low memory os kills.
https://twitter.com/crashlytics/status/235018252647010304
http://support.crashlytics.com/knowledgebase/articles/123408-do-you-catch-out-of-memory-crashes
Does anyone know of any crash reporting tools that catch low memory crashes?
Or, does anyone know of a way to detect these crashes w/out any added reporting tools?
Thanks!
You can't "catch" a low memory warning, but you can be notified in advance of them happening. You can implement applicationDidReceiveMemoryWarning: in your app delegate or respond to the UIApplicationDidReceiveMemoryWarningNotification. Aside from that, your app isn't notified when it's terminated.
You can also store transient data in NSCache, and it'll disappear under memory pressure.

Send low memory crash reports with QuincyKit?

Is there a way to send low memory crash reports with QuincyKit?
I looked through the code, and QuincyKit sends the crash reports found in:
/var/mobile/Application//Library/Caches/crashes
However when the app crashes due to a memory warning a file doesn't get created in that directory. I can view the low memory reports in Organizer (type Unknown), but where is the file located?
Can QuincyKit be modified quickly to send the memory reports?
Unfortunately this is not possible.
Out of memory crashes are actually kills by the watchdog process. Whenever you kill a process, there is no crash happening. The crash reports for those that you see in Organizer, are arbitrary reports written by the watchdog process that did the kill. So the only system that can provide information about these, is iOS itself.
It is not possible to retrieve the memory reports.
However, it would be possible to notice:
that a memory warning had been received and record the memory usage at that time - and
that X seconds later the application was no longer running (by maintaining a simple watchdog thread).
You could then deduce on the next run that the application had probably been killed due to an out of memory condition, and you would have some information about the memory usage at that time. Indeed, you could extend your memory warning handler to report the size of any caches you were running (and also to clean them up at the same time, thereby reducing the likelihood of a crash!).

Can an iOS application receive a memory warning in the background?

When an application is in the background and another application is running and is requiring more memory, can the app in the background receive a memory warning? Or can it only get killed from the memory without any warning?
If it's the latter, should I manually free up memory (cache) in the "applicationDidEnterBackground" method so that there is less chance that it will get killed?
Thank you very much!
Yes, your application can receive a memory warning while in the background. Your application only gets killed immediately if the system really needs the memory, but it'll play nice and ask your application to return memory on its own first. If the system is satisfied it won't kill your application.

Resources