views:

183

answers:

2

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

A: 

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.

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 :-)
A: 

This helped me out a while ago

http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/

lewiguez
Thanks that looks like it is the problem. I'm new to this though and having difficulty implementing it. Would I just replace each [UIImage imageNamed:@"rain-loop0001.png"] with [self thumbnailImage:@"rain-loop0001.png"] (after of course adding the function and dictionary)? I don't get errors but my animation doesn't run...