UrbanApps / UAModalPanel

An animated modal panel alternative for iOS

Home Page:http://code.coneybeare.net/uamodalpanel-an-open-source-modal-panel-alter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leak?

ddaddy opened this issue · comments

When I run your example project through Instruments/Leaks it shows me some leaks after the panel has been opened, closed, opened and closed again.
I'm just wondering if this is a leak in the code, or a bug in Instruments.
I'm using Xcode 4.5 beta so it's possibly a bug.

Have you tried running instruments on this?

Thanks

The Example project has no leaks, even running on 4.5 beta, so any leaked objects are ones you may have inadvertantly introduced. What is the leaked object your version is reporting?

Please see screenshot http://postimage.org/image/o1f435jhn/
This is using a fresh download and just running the example on Xcode 4.3.3 on iOS 5.1.1 and opening/closing a popup several times.
I don't really know how to use Instruments properly, but this screenshot should help.

Thanks

Hmmm, i don't know why this didn't show for me before. Looks like you are right, there is a leak caused by not properly releasing the onClose and onAction blocks.

I will update the code.

Thanks. Still getting some more after updating though. Screenshot here http://postimage.org/image/3juprwpd7/

I opened 100 panels on the current code and could not reproduce the leaks you are seeing. Are you sure you are on the latest code? What version of iOs are you building with, and what version are you running on?

I've just tested it again. Re-downloaded the latest zip and tested on Xcode 4.3.3 on a 3GS running iOS 5.1.1 and also on Xcode 4.5 on a 4S running iOS 6 and both showed me leaks. http://postimage.org/image/ppzus81e5/
I set the snapshot to 5 seconds and open then close a panel between each snapshot.

Ok, well since you can duplicate them and I can't, please feel free to fork and fix, then submit a pull request and I will be happy to take a look.

I was just thinking... what compiler are you using here, that might make a difference.

Sorry, that previous, previous comment sounded rude. I wasn't seeing leaks before while using the simulator, but when I hopped on to profile on the device, the leaks started showing for me as well. I spent about an hour looking into this, but didn't find anything revealing so I am not going to look into it anymore for such relatively minor leaks. They may be unfixable leaks originating from within Apple frameworks.

Please see my overall philosophy on leaks here. If these small leaks bother you, please do take the time to look into it and I will merge any fixes you find, but I just don't have time to hunt down these small ones.

No problem, thanks for the last reply.
I only started learning obj-c 18 months ago coming from a VBA background, so the memory side of things has always been my weak point yet I've become obsessed about leaks.
I spent 1.5 days going through my code to fix tiny leaks in the app i'm working on with little success. Reading your blog post has given me a great insight and I will try not to obsess over it now. Like you say, it could be framework leaks anyway.
I've used your code from here in 2 apps now, so many thanks for sharing it.

I've just been watching the WWDC 2010 talk on using Instruments so thought i'd give this another look.
The leak has something to do with the roundedRect function. I've removed this line from setBorderColor:
self.roundedRect.layer.borderColor = [borderColor CGColor];
and this line from setContentColor:
self.roundedRect.backgroundColor = contentColor;

and so far it seems to have cleared the leaks. I can't notice any change in function either.

Right, this is identified by your screenshots earlier, but those lines are necessary for the border color of the panel to be something other than white.

I've been using instruments and have also found various leaks, not just this one.

Feel free to submit a puill request if you think you have found something within UAModalPanel. Here is my policy on fixing minor leaks: http://code.coneybeare.net/why-i-no-longer-worry-about-minor-memory-leak