| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
I think this is the #1 problem with using autorelease excessively.
I am not promoting the use of retain] autorelease] (I dislike slowness :)), but I don't mind it to be the documentation default.
I do.
1) It creates more problems than it solves (masking/delaying erros until the autorelease pool pops)
2) The problem it 'solves' is exceedingly rare in practiceAgreed.
3) It actually doesn't even 'solve' that, because important cases are exceptions (collections, 'performance critical' code)
4) The real solution in those exceedingly rare cases that need it is trivial: let the caller retainI agree very much with this. I've been programming Cocoa for about 7-8 months now and when I first ran across an accessor returning a string, my FIRST instinct was that I should retain it, especially if I'm getting rid of the object I got it from.
5) Having the retain in the calling code makes it intention revealing, showing what you actually wanted to do at that point
6) Due to (4) it complicates the rules instead of simplifying them
7) It also complicates object lifetimes / the object ownership rules
8) It creates expectations of "safety" that an imperative language can never fulfill
9) The cases where it applies are cases where you need to think about your sharing semantics anyhow (see 5)
10) The performance cost (factor 10) is quite significant, and non-localized
11) KISS says: just say no! ;-)
That being said, I have no problem with it being listed as an option, and people deciding what they want to do. However, I do have a problem with it being listed as the default, most of all because of (8. Each time this subject comes up and more and more really smart people fall into similar traps about the 'safety' of the technique convinces me more and more that there is a real problem.
| References: | |
| >Re: Memory Management (From: Marcel Weiher <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.