0

I have an animation which works fine in the simulator but crashes on the device. I am getting the following error...

Program received signal: “0”. The Debugger has exited due to signal 10 (SIGBUS)

A bit of investigating suggests that the UIImages are not getting released and I have a memory leak. I am new to this so can someone tell me if this is the likely cause? If you could also tell me how to solve it then that would be amazing.

The images are 480px x 480px and about 25kb each. My code is below...

NSArray *rainImages = [NSArray arrayWithObjects:
                           [UIImage imageNamed:@"rain-loop0001.png"],
                           [UIImage imageNamed:@"rain-loop0002.png"],
                           [UIImage imageNamed:@"rain-loop0003.png"],
                           [UIImage imageNamed:@"rain-loop0004.png"],
                           [UIImage imageNamed:@"rain-loop0005.png"],
                           [UIImage imageNamed:@"rain-loop0006.png"],  
                           //more looping images
                           [UIImage imageNamed:@"rain-loop0045.png"],
                           [UIImage imageNamed:@"rain-loop0046.png"],
                           [UIImage imageNamed:@"rain-loop0047.png"],
                           [UIImage imageNamed:@"rain-loop0048.png"],
                           [UIImage imageNamed:@"rain-loop0049.png"],
                           [UIImage imageNamed:@"rain-loop0050.png"],
                           nil];


    rainImage.animationImages = rainImages;
    rainImage.animationDuration = 4.15/2;
    rainImage.animationRepeatCount = 0;
    [rainImage startAnimating];
    [rainImage release];

Thanks

2 Answers 2

0

I'm pretty sure you're crashing because [NSArray arrayWithObjects:] returns an auto-released object which you're storing to rainImage. Then at the bottom you're releasing rainImage again, thus over releasing it.

1
  • I have tried deleting the release statement but this doesn't make a difference. The link above suggests it's using imageNamed which is causing my problems. Thanks for the heads up on this though :-)
    – user157733
    Jun 7, 2010 at 21:09
0

The root of the problem is that you are running out of main memory because you have too many decompressed images in memory, see my answer to uiimage-animation-causing-app-to-crash-memory-leaks for the reason you should not be using UIImageView.animationImages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.