0

I am using ARC and the app crashes saying received memory warning. I have used the apple instruments and got

http://tinypic.com/view.php?pic=21kedxt&s=5

It looks like I do not have any leaks but I cannot find where is wrong. The crash has to do with the memory and due arc I cannot use release and any sort. It is my first time dealing with memory usage using arc. Is there away I can Debug this since I am dealing this for nearly two months. I have my code on my git hub so it will be helpful if you look at it. You can find it here.

I am confused now that it may because I need to set the UIImage instant to which the user capture the image to nil each time. It looks like it is creating the instance again without dealloc the old image. How am I able to clear this stuff. I really need help. Thanks.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
poradi12
  • 67
  • 1
  • 5

1 Answers1

0

The most likely solution is adding some @autoreleasepool {} statements to your code. If you have a loop that is allocating a lot of memory, the memory may not be freed until your application gets back to its main run loop.

You will want to change your loops that iterate many times to look something like this:

for (id value in largeArray) {
    @autoreleasepool {
        //code that creates autoreleased objects
    }
}

In the above code block, each time the loop finishes, all autoreleased objects that were created inside the pool will be released and their memory freed for use.

Some more info can be found in this question

Community
  • 1
  • 1
Simon Goldeen
  • 9,080
  • 3
  • 36
  • 45
  • If the app was releasing memory, but simply not frequently enough, this would have been a fine suggestion. If he was trying to simply reduce the high water mark of his app, `@autorelease` pools are a grand idea. But if the app isn't releasing the memory at all, this won't help. He has a leak and autorelease pools won't fix that. – Rob Sep 04 '13 at 02:49