Reputation: 101
Can anyone help me? my app crashes on walkthrough, i had NSZombies disabled and i also had this code
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
but my app still crashes. The app contains images and some webviews that loads local images. Please instruct me how to optimize the app to avoid crashes.
Thanks in advance
Upvotes: 3
Views: 8489
Reputation: 101
I somehow found a way to amplify memory usage, i just need to execute removeAllCachedResponses for every viewDidLoad of ViewControllers because the didReceiveMemoryWarning was quite late or being delayed to clear cached responses when the memory warning is triggered, it may not look good on the code but it prevents to store and fill up memory and caches. I can't still call it a solution but it is somehow a efficient preventive method to avoid memory leak.
Upvotes: 0
Reputation: 69
When ever your are done with any allocated objects, set them to nil explicitly to free up memory.
Even if you are using ARC, this will speed up the clean up.
Upvotes: 0
Reputation: 15339
The screenshot shows multiple errors:
The app got killed by the system because you are allocating way too much memory.
Using 261.4MB
memory is way too much! You say that you are loading local images. Make sure those images are as small as possible (in pixel size) and only kept in memory as long as they are needed on the current view. There are many discussions here on how to do that. If you don't find a solution, post a new question with your code, details on how many images and their pixel size, if you are using ARC or not, and also what you tried to fix it. Use the Allocations Instruments tool from Xcode to find out where in your code you are allocating too much memory.
The console log shows lots of autolayout constraint issues.
These should also be fixed. Post a new question with more details of such an issue if you can't fix it. There are also many discussion about such issues here that should help. Use the search feature of this website!
Upvotes: 3