10

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?

4

2 に答える 2

0

あなたが投稿したコードに明らかなリークは見られませんが、画像を再描画しようとしているだけなら (おそらく即時解凍を強制するため)、それは驚くほど複雑な方法です。これを行うだけです:

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

うまくいけば、あなたが見ているリークが修正されるでしょう。

于 2013-11-07T14:03:39.407 に答える
0

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.

于 2014-04-07T16:01:02.373 に答える