Showing posts with label memory. Show all posts
Showing posts with label memory. Show all posts
Tuesday, November 1, 2011
Mobfox leaks
After hours and hours of running Leaks instrument and pulling out my hair on my own project, I finally re-ran Mobfox's MobFoxDemoAdv project with Leaks and found that it does leak. The first time for some reason it didn't, this time, it did. I ran it for 4 minutes and in that timespan it leaked a couple times.
Tuesday, June 21, 2011
Memory Problems
If you see the message "Received memory warning." in the debug logs you can check on the following links to first see what is happening when this low memory warning occurs. They explain all about didReceiveMemoryWarning and viewDidUnload :
In the header file:
More tips can be found here.
For starters you can nil out all of the view controller's IBOutlets in viewDidUnload and release any objects that can be recreated in viewDidLoad.
To altogether try to avoid low memory problems, you can try some of the tips in the link below. The most effective one that worked for me is to not use UIImage imageNamed method so that the images are not cached. Once cached you have no way of getting rid of it. Not using that method saves a lot of space if you use a lot of images. Below is some code that can be used to extend UIImage using categories.
In the header file:
#import
@interface UIImage (DoNotCache)
+ (UIImage *)newImageNotCached:(NSString *)filename;
@end
And in the implementation file use:
@implementation UIImage (DoNotCache)
+ (UIImage *)newImageNotCached:(NSString *)filename {
NSString *imageFile = [[NSString alloc] initWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], filename];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imageFile];
[imageFile release];
return image;
}
@end
More tips can be found here.
Subscribe to:
Posts (Atom)