dealloc problem

Discussion in 'iOS Programming' started by thomasjt, Jul 8, 2009.

  1. thomasjt macrumors newbie

    Apr 16, 2009

    So, I suspect I need to read the memory management guide, and thankfully I have printed it out. And I shall read it in all its glory tomorrow. In the meantime though, can I ask something?

    my AppDelegate creates a single object known as Game. Game then creates two objects; Data, and View, which do what their names imply.

    In Games dealloc, it calls both [data release] and [view release]. Unfortunately, while data's dealloc method is getting called just fine, views dealloc method isn't. Moreover, if I then call [view release] a second time, I get a crash because view is already released!

    How can view already be released if it's dealloc method isn't getting called? But then when called again the dealloc method works but crashes...?

    Any help would be greatly appreciated.


  2. ChOas macrumors regular

    Nov 24, 2006
    The Netherlands
    Hi there!

    Is it possible to show the relevant code bits (alloc/retain/release/dealloc/etc) ?

    Is this at the end of the program ? Because I seem to remember that not all deallocs are thebn guaranteed to be called.
  3. thomasjt thread starter macrumors newbie

    Apr 16, 2009
    Thanks for your offer of help ChOas but I think I've fixed it (for now).

    Can I ask a question though?

    In your dealloc method for a class you should release any class ivars, right? What about ones that are just created during a routine? Do you just need to release them at the end of the routine?


  4. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Come back when you've finished reading the Memory Management Guide and see if you still need answers to these questions.

Share This Page