I know that probably it's a good practice to release appdelegate's ivars in its dealloc method, but practically, does it makes any sence?
As I understa开发者_开发知识库nd the appdelegate of an iPhone app will live in memory while the application is running and all memory will be freed anyway when it's closed.
Thank you
Good memory management should be a habit. The more you have to think about when and where it applies the more likely you are to make mistakes. That may be reason enough alone to do it.
Flip the question around - what do you lose by adding those releases? Is it really much effort to add them?
Some more questions:
- What happens if the architecture changes a little and the app delegate is released early?
- What if one of the objects being released does additional clean-up (such as saving out its state) in its dealloc (ignore for a moment whether that's a good idea).
- Will it generate noise when you Build & Analyze?
Personally I do all my app delegate releases. You could argue that it's not worth it - but I hope I've given you some reasons to consider otherwise.
[update]
I've since blogged about an alternative memory management technique that may be relevant - using (via Objective-C++) smart pointers!
精彩评论