PDA

View Full Version : dealloc problem




thomasjt
Jul 8, 2009, 06:28 AM
Hello,

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.

Cheers,

Tom



ChOas
Jul 8, 2009, 06:47 AM
Hello,



Any help would be greatly appreciated.

Cheers,

Tom

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.

thomasjt
Jul 8, 2009, 08:04 PM
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?

Cheers,

Tom

dejo
Jul 8, 2009, 08:06 PM
Come back when you've finished reading the Memory Management Guide and see if you still need answers to these questions.