I am working on an app with xml parser, uiwebview, navigationcontroller, displaying a lot of images on the main controller, that remains in the memory throughout the whole life of the app. I store my data using core data.
I tried to figure out the memory footprint of the application since I am getting the following warnings:
Received memory warning. Level=1 app delegate received memory
warning main controller received memory warning main controller
received memory warning RSSItem received memory warning
Received memory warning. Level=2 app delegate received memory
warning main controller received memory warning main controller
received memory warning RSSItem received memory warning
The footprint is around 4MB, and jumps up to around to maybe 10 when I drill down and display UIWebViews with a significant number of images.
Is that footprint too large? I assume that there are apps out that are considerably more complicated. From what I understand the apps have 40-70MB available, give or take, but definitely not 10MB limit. Anyone has any insight what can I do to fix it or work around the problem. I do not have leaks.
I am afraid that the real problem is not the footprint but something else I am not aware of.
Thanks for any help.
you have memory analysis tools in Instruments.app - this will show you much data related to allocations in your app.
if i had to guess: destroy images which are not visible.
Related
All the used viewcontrollers and controls are released and deallocated upto my knowledge and Also tracked through Instrument and generic Analyzer. But my app receives low memory warning Issue.
i have heard abt low memory warning levels.If they exists how to identify them via notification.
Meanwhile my app consumes only 16 mb RAM and works perfectly in simulator bt crashes in device.
Plz join hands.
Low memory warnings are normal and you can't prevent them from happening because your user might be running other games at the background which is out of your control.
What you really need to care is to properly release all retained but recoverable objects and caches when you received low memory warning. That's it.
IN below function,just comment the code
- (void)didReceiveMemoryWarning{
// Releases the view if it doesn't have a superview.
// [super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
IT will solve any problem due to memory warning.Memory warnings are normal and don't need to handle them
I am playing around with Instruments. And I just recorded/profiled for memory leaks, I had very few memory leaks, but an overwhelming amount of allocations just keep going even when my app just opened. Here is a screenshot after using the app for less than 10 seconds.
And as I keep using the app it just keeps increasing and increasing.
The weirdest part is most of the allocations are coming from classes I don't know like:
Foundation
Altitude
lbdispatch.dylib
But it could be from the SBJson and the other classes I imported and added for JSon and XML.
But is this a lot of memory allocations? Is too much bad???
Yes and no, it depends on what you are doing, if you allocate for example a lot of strings, lets say you allocate 1000 strings these allocation perse are not bad, but it depends on your logic view of your application, if you really need all the strings at once and you need them to be allocated and alive through all the steps of your application, then you dont have anything to do, your application just needs alot of memory,
However on the other hand, you may find some other ways to logically structure your application, like for example you could only allocate each of the 1000 string once you need it.
A very abstract answer is, if your app requires a lot of memory and there is no way to use some techniques such as lazy loading, or caching, then you dont have any other solution
But if you can restructure your application to use lazy loading, caching, allocation pools it would bee better
Please note: that you could let iOS sdk help you, by implementing correctly the memory warning callbacks in your application, in such a way that whenever you receive a warning, you start releasing any resource that you dont currently need
Also, do you have Zombies on? Zombies default to not actually removing any allocations, so memory is never deallocated. Always test for memory leaks with Zombies off.
I'm trying to debug a mysterious app crash that happens after running the app for a few hours.
My hunch is that this may be memory related, as I've not done any memory optimization since starting to build my app.
I'm looking at my application with the "allocations" instrument and I see these numbers:
All allocations 4.70mb
Living 51072
Transitory 357280
Overall Bytes 100.23mb
Overall 408000
Which is the important number here? Does my app take 4.7 Mb of memory or 100 Mb? At which point should I be concerned about my app being killed for memory reasons? I want to avoid premature optimization :)
Since I'm using ARC and TabBarController, most of the controller related memory seems to be out of my hands, unless I find out how to create a tab and lazily init a controller when that tab is first touched.
Thank you!
I am mystified by a memory leak: It says the responsible library is "AppSupport" and the Responsible Frame is "CPRecordLoadHandler". Not quite sure where to begin. I know that it's when a specific view controller loads so obviously I can narrow it down a bit but I can't find a single result in Google that explains what a CPRecordLoadHandler memory leak comes from.
I'm having strange effects with my app. I implemented my own PDF viewer. It shows ONE page at a time. Using Instruments Activity Monitor I see that my real memory is constantly at around 50MB.
After switching pages forth and back a couple of times I receive a memory warning level 0.
I do my best to react on it and sacrifice the low-res background image I'm rendering first to show something until CATiledLayer catches up.
Does not help. A few pages later I get memory warning level 1 and level 2 and after a few more pages my app gets killed with reason "9". Memory NEVER goes above 50MB!
Why do I get those warnings in the first place? There IS enough memory available.
This is happening on on iPad running iOS 4.3.
I don't think there's anything mysterious going on here -- which I'm sure is not what you wanted to hear. There are no absolute figures of "safe" amounts of memory to use. The rule is: when the OS tells you you're using too much, use less. It will jettison background processes first and in preference to your foreground app but there are still limits.
In the "olden days," you used to be lucky to get 20Mb. I'm sure you can safely get more than that on an iPad but, apparently, it's less than 50Mb.
You don't say how much memory you free by releasing the background image, but it seems that you need to be caching less data. You might also want to check Leaks (also in Instruments) to make sure you're releasing the objects you think you are.