Closed bmueller closed 11 years ago
I have an ARC project running the current BlockAlertView (non-ARC) and get no leaks in Instruments.
What type of object does it say it's leaking for you? Can attach screenshots/the instruments run?
It's leaking a UIResizableImage - looks like it's the "background" UIImage object in the BlockAlertView class. I'm calling the following line in both the "initialize" method and the "initWithTitle" method:
background = [[background stretchableImageWithLeftCapWidth:0 topCapHeight:kAlertViewBackgroundCapHeight] retain];
I need to call it in both methods to ensure that the theming I apply to the background image is correct. I suspect that calling retain twice is what is causing the issue, but I'm not familiar enough with retain counts, etc to know how to solve this issue. Any ideas?
Ahh, if it's in something you customized then I can't really give an answer as I don't have your code. Why are you calling that method yourself instead of just replacing alert-window.png with your custom png?
Yeah, I figured, and the leak's not really that big of a deal, just annoying :)
And I have to call it a second time because when a new theme gets applied and the background image has to be replaced, for some reason the caps on the stretchable image get all messed up if it only gets called during the initialize method.
Well, when you're calling it in the init method, add this before to avoid the leak:
if (background) {
[background release];
background = nil;
}
Works like a charm, thanks for the help!
I'm seeing a memory leak in Instruments whenever I open a BlockAlertView. (My project's running ARC, but I'm using a non-ARC version of BlockAlertView.) Has anyone experienced this? And any ideas on how to fix?