10
votes

My app has been receiving a low memory warning with a repetitive action and eventually crashes. When I profiled in instruments, I only see 5.7 MB of living bytes at crash. (The crash shows no traceback, no errors, etc. It just terminates, which is indicative of a memory crash.)

Why is my app crashing with such a low memory footprint?? I've been testing on iOS 5.1 on iPad 1.

Instruments screenshot

Edit:
I was able to fix the crashing. It was due to an extra retain call on an object that has 3 UIImages as properties. An accumulation of these objects was causing the memory warning and crashing.

However, the question still remains: why did Instruments show that there were only 5.7MB of live bytes? Could this be due to UIImage's automatic caching?

2
Crash may not due to low memory. What is the crash error?Raptor
Good thought, but there is no traceback or error given. It just terminates. (I've added this to the question in an edit.)Kiefer Aguilar
It seems that you should really identify the precise source of the crash. See My App Crashed, Now What?Rob
another think is if in instrument you add with the button library the "memory Monitor" tool you can see also when e how your memory go downMirko Catalano
This can be an issue in the memory tool itself because a similar thing happened to me when a NSMutableString kept growing due to a bug in my logic. All I saw was memory warnings and the application crashes after a few but the memory usage at the time was only ~8 MB. The symptoms were the memory quickly grew to ~8 MB, kept there for about a few minutes and warnings came. After some time, the application hang and crash, make any sense ?chathuram

2 Answers

0
votes

I can't see any obvious leaks in the code you've posted, but if you're just trying to redraw the image (presumably to force immediate decompression) then that's an amazingly complicated way to do it. Just do this:

- (void)loadImage:(UIImage *)image
{
    UIGraphicsBeginImageContextWithOptions(image.size, image.scale);
    [image drawAtPoint:CGPointZero];
    self.someImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
}

Hopefully that will fix whatever leak you are seeing.

0
votes

Have you set NSZombieEnabled to YES in the environment variables?

When zombies are enabled memory is never really freed but retained in a zombie pool for debugging references to invalid pointers.