2
votes

I am having this strange problem in my universal iOS app. While profiling the app, I don't see any valid memory leak in instruments tool. Still size of allocation keeps of increasing by 50-100 kb on every page change. Leak instrument only shows some leaks with Responsible Caller as mem_alloc.

After some time of usage, the app starts receiving memory warnings and some more time in the app and the app crashes. Interestingly, total memory allocation at this time varies between 6 to 12 MB. App doesn't show any stack information either, when I backtrace in debug mode.

I am totally clueless that why this crash is occurring. Any help will be appreciated.


Attaching some of the screen-shots of my instrument. enter image description hereenter image description hereenter image description here

2
have you tried with static memory analyser?rishi
I don't have any idea about static memory analyser. Would you mind explaining me a bit?Dipak Mishra

2 Answers

3
votes

You need to check for memory allocations with following in your app -

  1. Using Instruments check Allocation and Leaks

  2. Using Static memory analyser check static memory leaks. To use this either use "cmd+shift+B" or go to "Xcode -> Product -> Analyze"

Also you need to ensure proper release of your view controllers.

1
votes

Though it's been really long that I had asked this question and didn't get any proper answer. While visiting back to my question I think solution to this problem will be helpful for other early starters. So here I am posting my solution that worked:

Real culprit in this case was the way I was using images in the app. I was simply using it by calling [UIImage ImageNamed:]. Practically this method leaks the memory of image's size.

Solution to this problem is to use image by calling ImageWithData (see below code):

NSString *fileLocation = [[NSBundle mainBundle] pathForResource:fileName ofType:extension];
NSData *imageData = [NSData dataWithContentsOfFile:fileLocation];
[UIImage imageWithData:imageData];

Hope this helps someone.