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: need help understanding and learning memory managment..




On Aug 31, 2005, at 12:44 PM, Eric Morand wrote:


Le 31 août 05 à 19:35, Brian O'Brien a écrit :


For one thing is it possible to print out the current retain counter of an object?
Just for some debugging purpose?



- (unsigned)retainCount does this ! This is an instance method of NSObject.

Be aware that you really shouldn't pay attention the results given by retainCount, since there is often a great deal of behind the scenes retaining going on, and so the values you see may not be at all what you expect.


Simply using a variable as a parameter to another method can cause that retain count to go up (and possibly cause other variables retain counts to go down).

For example

    foo1 = ... some  object
    foo2 = ... some other object

[x doSomething: foo1];
// at this point, foo1 may be +1, or maybe not
[x doSomethingElse: foo2];
// at this point, foo2 may be +1, and foo1 may even be -1, or maybe not


As a result of these values changing in ways that are often non- obvious, treat any conclusions drawn from the values of retainCount (or the delta of those values) with a grain of salt.

Glenn Andreas                      email@hidden
 <http://www.gandreas.com/> wicked fun!
quadrium | build, mutate, evolve | images, textures, backgrounds, art

_______________________________________________
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: 
 >need help understanding and learning memory managment.. (From: "Brian O'Brien" <email@hidden>)
 >Re: need help understanding and learning memory managment.. (From: Eric Morand <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.