in my app i have a UIWebView and in that web view i am loading some text and images. I am getting those datas by parsing from an rss feed. When large datas get loaded my app get crashed saying that memory warning. How to avoid this memory warning issues in my app
Sorry, but there's only one real answer to this: use less memory.
When you get the memory warning you should clear out any caches or temporary data that can be recalculated. As you've found, if you don't do that iOS will kill your app.
Related
I've been surprised that iOS 5.1 does not manage memory quite as I expected. When the device is running a lot of apps, it appears that iOS does not kill memory hogging apps in the background, but sends memory warning to my own app as well.
For example showing a UIImagePicker crashed the app on two test devices. Double tapping the home key and killing some of the background apps prevents the app from receiving the memory warning and crashing.
I'm wandering if iOS would not free up memory for me, is it acceptable to show some sort of alert view notifying the user that the memory is low and some of the background tasks have to be killed?
I'm at a loss of how to deal with such events - does it take time for iOS to clean up some memory (while apps respond to memory warnings)?
iOS does a lot of stuff before bothering you with memory warnings, including killing backgrounded Apps. Since iOS 5, iOS is even going to annoy you as less as possible with memory warnings, meaning that you only get one if there really is a need for you to get rid of stuff that is using memory but not needed right now (and that you can safely recreate in the future without taking hours for it). If your App crashes without giving you a memory warning first, chances are that you allocated so much memory that the system can't tell you that its running out of memory before it decides to kill you, the reason for this is that the memory warning is scheduled on the runloop of the main thread and until you give the runloop time to do another iteration, you won't receive the warning.
Also, Apple doesn't like you to tell the user that there is a memory problem; Its your App that has to deal with it, not the user! So its very very likewise that your App gets rejected if a memory warning comes up while the review team is reviewing your app (rumor says that they send these warnings to test how your App reacts to them)
Soo, to sum it up: iOS does work like you expected by killing what it can and even shutting down other system daemons, only after this happening you will be notified that memory is low. The correct way to respond to these warnings is to free up as much memory as you can, start with the big stuff that can be easily recreated in the future (eg. if your app shows loads of pictures but not all are visible at a time, throw away the ones that aren't visible right now). Telling the user is the wrong way to deal with the problem and Apple doesn't like it, so try to solve the problem on your end.
I am in the final stage of developing an iPhone game and I am dealing with a crash that appears to be memory related.
It happens only on the device when I load a game level several times (10 to 15 times). I get some memory warnings around the 8th time and if I keep loading the same level it finally crashes with this message on the console:
Program received signal: “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library
"/Developer/usr/lib/libXcodeDebuggerSupport.dylib")
Some goolge search told me this message usually means the app has run out of memory.
I ran the app under instruments but it didn't detect any memory leaks and the total allocation remained around 1,5Mb (both live and overall bytes) reaching 5,4Mb for a fraction of a second everytime I loaded a level. This doesn't seem a lot since a leaky test app didn't crash before allocating more than 30Mb on the same device (iPhone 3GS). I am new to instruments so maybe I am missing something.
I ve been struggling with this bug for days now and I would be really thankful if someone could point me in the right direction.
Check in Instruments the Activity Monitor instrument. You'll find the correct amount of RAM you are consuming at any given time. The Allocations instrument is not really an indicator of RAM usage. It will however help in finding things that have been allocated and not released. Use heapshots in Allocations to find out where things are being leaked.
http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/
Yes, your searching was right "this message usually means the app has run out of memory"
Please read memory management documentation from apple and release your objects properly if where you getting memory leaks.It will reducing memory warnings as well as your code will work fine.
When you allocating simultaneously objects when new level loading it will indirectly premises you allocating objects but you not able to delloc properly, it means that you creating new memory for new object but still old object is in memory. After this scenario why not you got memory warning?
Hi I am basically loading a webpage within my app and every time I open the webpage
my app crashes after it receives 2 memory warnings(didreceivememorywarning) of level 1 and last on is randomly level 1
and level 2 and finally app receive signal 0 and app crashes on the spot. can't we load just a single webpage
You're running out of memory. Either your web page (and included images and such) is too huge, or your page contains javascript that is allocating too much memory, or something else in your app is using too much memory and the web page is just the straw that is breaking the camel's back.
I have an app that stacks quite a nice amount of views on top of each other.
At some point I receive a Memory warning level2 (which is kind of expected).
The thing is, when I run Instruments, I don't have any memory leaks and the app takes up something like 9-10MBs... which is not that much, I'd say?
Question is: how much memory can an app consume, a.k.a. how much RAM does the iPhone have?
I know that I can respond the the receivedMemoryWarning and free up some memory - but this would mean that I'd have to get rid of some of the views, which is not the solution I'm looking for...
The app didn't crash so far - but I'm concerned that it might crash on other user's iPhones...
An application can use 30-40 MB of real memory or greater then this and there will not be a problem. When you are getting a memory warning level-1, till then there is not a problem, but if you get memory warning level-2, then the app might or will crash after some time.
solution is, when you get memory warning level-2, inside your delegate method, release some memory which you are not using currently.
You app won't crash anyone's iPhone. The system will just kill your app. Anyway 3GS is rumored to have 256Mb while iPhone 4 has 512Mb. It still won't matter because when you receive a warning you better comply.
Try reducing the amount of views you have or unload the ones which the user can't see.
According to Instruments 'Net Bytes' of my app are never more than 2MB yet sometimes I receive memory warning and the app crashes because some views on the stack are unloaded by force.
I'd like to know what is the typical memory footprint where system would not send you memory warning and unload the views ?
I have so far tried this on OS 3.1.2 on iphone 3GS and 3G and with 3G giving warning almost 80% of the time I test the app on it.
The problem isn't that you're using to much memory. It might be some other application that's using the memory and causing your app to receive a memory warning.
The problem probably is that your not setting your views to nil on viewDidUnload.