Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String memory leak



Hi Paul,
You're right, I had gotten myself confuzzled on a lack of sleep and
abortive Red Bull kickstart. I suck. My apologies everyone.

When I was a newbie (rather than my current inept semi-newbie status)
I wasn't really sure the deal with Cocoa array retainment strategys.
As part of the Cocoa framework methodology, they work entirely as you
would think. If you don't entirely see that methodology through yet,
they can appear a little tricksy.

It seems strange that this:

SomeObject *object = [[SomeObject alloc] init];
[array addObject:object];
[object release]; // container now "owns" object we are done with

is valid. I would have seen this as the array having a pointer to an
object I just happily released, and now have no guarentee of it's
existance. But yes, the array retains the object for itself until it's
removed or the array itself is released.

Of course, this is all valid and totally correct and expected
behaviour. It's just a little new if you have thought of arrays with
objects in soley as a way of storing a lot of object pointers at once.

Chris
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >String memory leak (From: Bruce Truax <email@hidden>)
 >Re: String memory leak (From: "Chris Lewis" <email@hidden>)
 >Re: String memory leak (From: Paul Forgey <email@hidden>)



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.