Re: Memory Management (Part I)
Re: Memory Management (Part I)
- Subject: Re: Memory Management (Part I)
- From: Marco Scheurer <email@hidden>
- Date: Fri, 1 Aug 2003 17:32:11 +0200
On Friday, August 1, 2003, at 08:12 AM, Marcel Weiher wrote:
Where on earth did you get that from?!? Reference counting is a
form of garbage collection. It isn't a perfect form of garbage
collection because it can't handle cycles, but it still is a form of
garbage collection. Retain/release, of course, is not fully
automatic garbage collection, because it is at best semi-automatic.
The previous poster states that it is done to "work a little bit more
like a garbage collected environment",
then I am saying: Don't think about garbage collection, just think in
terms of autorelease pools. It doesn't help to expand the domain,
then get certain amounts of expectations going, that it oughta be
doing this and that and then be disappointed, when it fails. Read the
sentence in context with the previous discusssion, it will make >> sense.
You obviously didn't understand what Marco was saying.
So just to make sure, what I meant was that the retain] autorelease]
pattern is added to the accessor method so that the caller doesn't have
to do it. The effect for the caller (the customer of the provided code)
is that of a pseudo garbage collected environment, where objects live
for as long as they are referenced. Of course we know that this limited
to a block anyway. (And also that it is even less interesting if the
purpose is too be able to manually release something on the following
line!)
On Friday, August 1, 2003, at 01:15 AM, Nat! wrote:
4) The real solution in those exceedingly rare cases that need it is
trivial: let the caller retain
But how will you know, when a case is exceedingly rare ?
You know this! With judgement, thinking, and common sense. Using
science instead of magic: making experiments when you have doubts or
when reality (bugs) shows that your theory seems wrong, instead of
relying on faith.
...
NSString *name = [person name];
[person release];
NSLog (@"%@", name);
...
...
NSString *name = [names objectAtIndex:0];
[names release];
NSLog (@"%@", name);
...
are equally unusual, suspicious code fragments. That the first one
should be authorized, but not the second one for performance reasons is
rather embarassing for the coherence of the kit, IMHO.
I wish Apple would fix NSZombieEnabled instead of inventing such
workarounds.
Marco Scheurer
Sen:te, Lausanne, Switzerland
http://www.sente.ch
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.