Re: Object ownership question
Re: Object ownership question
- Subject: Re: Object ownership question
- From: Brendan Younger <email@hidden>
- Date: Mon, 18 Jun 2001 23:20:12 -0500
There are some great tutorials around for this. In a nutshell, Cocoa
uses reference counting to determine if an object needs to be kept
around in memory or not. If a piece of code allocates a new object
( [NewObject alloc] ) then the object has a reference count of one.
Until it is released ( [NewObject release] ), it will stick around in
memory because the code that created it must still want it around. When
the reference count reaches zero (it has been retained and released the
same number of times), the object calls its own -dealloc method which
releases all memory associated with that object. Here are some links
which explain this more in-depth:
http://www.stepwise.com/Articles/Technical/HoldMe.html
http://www.stepwise.com/Articles/Technical/MemoryManagement.html
http://www.stepwise.com/Articles/Technical/2001-03-11.01.html
http://www.cocoadev.com/index.pl?MemoryManagement
There may be more, I just don't know of them. Have fun!
Brendan Younger