UIView being retained
I'm having real problems tracking down why my UIView isn't deallocing.
I have a UIViewController with severa开发者_JS百科l UIViews, all of which are IBOutlet properties that retain.
I'm sure to release the UIView in the dealloc method of the UIViewController. However the dealloc of my UIView is never called. I have no idea what else has retained the UIView.
All the other UIView in my UIViewController dealloc fine, just this one doesn't.
Does anyone have any good techniques for tracking down what could be responsible for this?
Regards, Rich
I would begin by going into the instruments application and selecting the "leaks" profile. Choose your application and run it to detect leaks.
When it detects your leak, click on the detail indicator by the memory address of the object that has leaked (your UIView). Here you will see your UIView getting allocated, retained, and released and which function call did it.
There is a good WWDC video titled "Session 311 - Advanced Memory Analysis With Instruments" if you want to watch that, they go over it in depth.
Be sure to read Memory Management of Nib Objects from Apple's Memory Management Programming Guide. It describes how to properly declare IBOutlets and when and how to release them in you view controller.
Short version: You should be setting the IBOutlet property to nil in ViewDidUnload
.
If that doesn't help, you could try running the Leaks Instruments tool and see if it can find where you're leaking your view.
精彩评论