[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bogus retain via NSEnumerator
From: |
stefan |
Subject: |
Re: bogus retain via NSEnumerator |
Date: |
Wed, 21 Apr 2004 08:46:07 +0200 (CEST) |
User-agent: |
SquirrelMail/1.4.2-3 |
Hi,
>> The Cocoa version of autorelease and the one documented in
>> the O'Reilly "Objective-C Pocket Reference" differ greatly. I like the
>> idea
>> of autorelease sending a release message to the object as soon
>> as the callee's stack frame is destroyed -- that makes a lot sense
>> and is consistent with how local object's (i.e. stack
>> allocated) are deallocated in C++.
>>
>> This whole idea of autorelease pools seems a little strange to me and
>> seems
>> as error prone as performing my own explicit memory management.
>> But I am new to Cocoa's memory management scheme, so the jury
>> is still out.
>
> You are comparing Apple's and oranges! All (repeat: ALL) objects in
> Objective C are dynamically allocated; none are allocated on the stack.
> Even in C++, dynamically allocated objects created with new are not
> automatically destroyed just because a variable that REFERENCES the
> object goes out of scope.
>
> The autorelease mechanism works very well once you understand it. The
> advantage is that typically a method caller who gets a pointer to an
> object back from the call doesn't have to do anything with it in terms
> of retaining it or destroying it. In C++, you would have to
> explicitly destroy the reference.
Here is a great introduction into Cocoa/GNUstep memory managment that
was very helpfull to me:
http://www.stepwise.com/Articles/Technical/HoldMe.html
greets
Stefan
- Re: bogus retain via NSEnumerator, Michael Ash, 2004/04/20
- Re: bogus retain via NSEnumerator, James Spencer, 2004/04/20
- Re: bogus retain via NSEnumerator,
stefan <=
- Re: bogus retain via NSEnumerator, John C. Randolph, 2004/04/21
- Re: bogus retain via NSEnumerator, David Stes, 2004/04/21
- Re: bogus retain via NSEnumerator, Pete French, 2004/04/21
- Re: bogus retain via NSEnumerator, Sherm Pendley, 2004/04/21
- Re: bogus retain via NSEnumerator, David Stes, 2004/04/21
- Re: bogus retain via NSEnumerator, Glenn Andreas, 2004/04/21
- Re: bogus retain via NSEnumerator, Michael Ash, 2004/04/22
- Re: bogus retain via NSEnumerator, John C. Randolph, 2004/04/22
- Re: bogus retain via NSEnumerator, David Stes, 2004/04/22
- Re: bogus retain via NSEnumerator, John C. Randolph, 2004/04/23