brow / leaves

A page-turning interface for iOS apps
Other
1.44k stars 332 forks source link

Crashes on iPad #26

Closed macinsmith closed 11 years ago

macinsmith commented 11 years ago

I modified a version of this to use with an app on the iPad. It would work in the simulator, but crashed on the iPad. I found that the problem was that the CGImageRef was being released, then passed back in - (CGImageRef) imageForPageIndex:(NSUInteger)pageIndex. Also there was a call to [UIImage imageWithCGImage:] that was not needed. Here is what my code now looks like

brow commented 11 years ago

The purpose of the lines you're removing is to retain the image until the end of the run loop. That's accomplished by creating an autoreleased UIImage just to own the Core Graphics image until then. It's an ugly hack.

If you remove those lines, then you're leaking an image every time this method is called, and your app will eventually be killed for hogging memory.

Is the crash occurring in a clean clone of Leaves, or just in your modified version?

brow commented 11 years ago

Closing due to inactivity.