Question on the dealloc method and memory leaking


#1

I noticed that in the first example of this Chapter (chapter 20) that in the class Asset we override the dealloc method inherited from this classes super NSObject (see Asset.m page 126 in my book).

We do this by declaring our own version of dealloc, and by doing so we use NSLog to output a message onto the screen. This message gives us indication that the dealloc method has been called.

This method however does nothing more in terms of actually deallocating the Object.

My question is: Would this not cause memory leaks to occur, because we have actually broken the chain of events that do the actual deallocation?

All comments welcome


#2

No, it will not cause memory leaks. ARC will automatically call the dealloc methods for each class in the hierarchy. In particular, because Asset inherits from NSObject, NSObject’s dealloc method will be called, which will deallocated the instance of Asset so that its memory can be reused.


#3

Thank you for the response.
I got this same response from ibex10.

I will have to study this a little more to make sense of it.

P.S.
Im very happy to have this book, its the best one I’ve come across so far, and coupled together with this forum, makes it a very effective learning experience. It has really helped me, and I have already recommended it to others, thank you and everyone else from BNR and this forum.