On Mar 3, 2011, at 4:35 PM, Kyle Sluder wrote: > On Thu, Mar 3, 2011 at 4:20 PM, Gerriet M. Denkmann > <gerr...@mdenkmann.de> wrote: >> But, taking my original example: >> >> NSAttributedString * attributedString = ... >> NSFont *aFont = [ attributedString attribute: NSFontAttributeName atIndex: >> 0 effectiveRange: NULL ]; >> NSString *fontName = [aFont fontName]; >> [ attributedString release ]; >> >> Now aFont no longer exists. >> So fontName, being a property of the no longer existing aFont, should have >> vanished also, shouldn't it? > > Replace "should" with "could." The point is that there's no guarantee, > and you need to be prepared for the case where it does. >
And anyway the argument, as specifically posed, is specious, because NSString is a very, very special case. Memory management for strings is utterly different from memory management for a normal object. Most strings are way over-retained and *never* vanish. Indeed, it is quite difficult to generate a string that *does* vanish if no one retains it. You can do it, but you have to hunt around for a while to figure out how. So arguing by analogy with what an NSString does cuts no ice whatever. Having said all of that, the OP should feel free to file a bug. I've recently filed about a memory leak in connection with NSMutableAttributedString, and have had this acknowledged as a known issue. So the idea that there might be something a bit funny with memory management in connection with NSAttributedString is not unreasonable. m. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com