I have a strange situation. I have a fairly memory intense process (image processing) running, but I've worked out all the kinks and it runs just fine 99% of the time.
However, if I put the app in an inactive or background state, when returning and trying to run the same process I get memory warnings and then the app crashes.
I have used instruments to analyze the memory footprint in the two use cases and the memory footprint is exactly the same. However, in the case where I do not put the application into the background (or inactive) it doesn't give me any memory errors and completes fine. In the use case where it was put into the background (or inactive) I get memory errors and it crashes.
Does anybody have any information on this? I have been scouring the net / irc / stack over / apple docs trying to figure this out. Is apple (iOS) reducing the amount of memory my app is allowed to run with after I return from the background? Is there any way to prevent this? Or am I overlooking some other more simple solution?
(Note, there aren't memory leaks)
Alright figured it out - iOS isn't doing anything stupid, it was of course the developer :) There was another component (ViewController) to my project which did some stuff when returning from the background, such as allocating memory. However, this view wasn't active so allocating the memory it needed proved to be useless. After cleaning up the code I didn't run into any memory errors.
Just for check, while starting any background process it should be in autorelease pool. Background processes are running parallel with main thread. So while performing any task on background we should look at the memory. This is a common error often found for leak. Also operations that deals with UIKit always runs on main thread. So if you process any data through background & want to show it on UI then that will be loaded on main thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With