Skip navigation.
 
mlRe: upper limit on retain count
FROM : Ali Ozer
DATE : Tue Apr 19 18:46:07 2005

We don't document an upper bound, but we try to provide reasonable 
upper bounds. If the upper bound is reached, we clamp.  So objects 
that are too popular may end up getting stuck around.

In practice most objects have 32 bits of retain count, although some 
of the more popular ones (NSString, NSNumber, etc) will go higher 
("millions of millions"). However, that should be regarded as an 
implementation detail that can change.

If you really need retain counts >2^32 on your custom objects, you 
can override retain, release, and retainCount to provide custom 
referencing counting. Typically these would be overridden for 
performance (for objects that are very frequently retained or 
released), but managing higher retain counts is another reason... 
Remember to make your implementations thread safe, if needed.

Note that your retainCount would not be able to report reference 
counts higher than UINT_MAX; however, this doesn't mean you can't 
have higher retain counts internally.

Ali




Begin forwarded message:

> From: "Ivan S. Kourtev" <<email_removed>>
> Date: April 18, 2005 13:43:59 PDT
> To: <email_removed>
> Subject: upper limit on retain count
>
>
> Hello,
>
> I wasn't able to find any documented upper limits on retain count 
> on 32-bit machines (or in general).  I am interested in knowing 
> this because I foresee a situation where I may have objects with 
> retain counts of hundreds of millions of billions and more.  So the 
> two questions I have are:
>
> (1) is there a documented limit to the retain count?
> (2) is there a documented behavior once the retain count max is 
> reached?
>
> Thanks,
>
> --
> ivan
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>

Related mailsAuthorDate
mlupper limit on retain count Ivan S. Kourtev Apr 18, 22:43
mlRe: upper limit on retain count Daniel Jalkut Apr 19, 07:05
mlRe: upper limit on retain count John Stiles Apr 19, 17:45
mlRe: upper limit on retain count j o a r Apr 19, 18:19
mlRe: upper limit on retain count Axel Andersson Apr 19, 18:44
mlRe: upper limit on retain count Ali Ozer Apr 19, 18:46
mlRe: upper limit on retain count Ondra Cada Apr 19, 18:57
mlRe: upper limit on retain count Ivan S. Kourtev Apr 19, 20:30
mlRe: upper limit on retain count Ondra Cada Apr 19, 20:55
mlRe: upper limit on retain count Shaun Wexler Apr 19, 21:05
mlRe: upper limit on retain count Shaun Wexler Apr 19, 21:09
mlRe: upper limit on retain count Scott Ribe Apr 23, 00:25
mlRe: upper limit on retain count Bob Ippolito Apr 23, 00:40
mlRe: upper limit on retain count Scott Ribe Apr 23, 00:51
mlRe: upper limit on retain count Bob Ippolito Apr 23, 06:57
mlRe: upper limit on retain count Johnny Deadman Apr 23, 18:44