views:

21

answers:

1

Hi, 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 understand 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

+1  A: 

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!

Phil Nash
Hi, thanks for your answer), I don't want to say that it's difficult to release them or I don't want to do it) I just asked it here to learn what people think about it. You gave good reasons))I want to ask, Is ot possible to release appdelegate early? will an app live without it?
Burjua
There's nothing magical about the app delegate. You certainly could release it, and the app would live on. Of course, it wouldn't do any of the things that were handled by the app delegate. :) But I'm assuming if you released it, you intended for it to stop functioning.
andyvn22