Re: upper limit on retain count
Re: upper limit on retain count
- Subject: Re: upper limit on retain count
- From: John Stiles <email@hidden>
- Date: Tue, 19 Apr 2005 08:45:10 -0700
You know, the computer only has 4 billion bytes of memory, and even the
most trivial of objects is 8 bytes (it needs an isa and a refcount).
FWIW, to answer the original question:
- refcounts are 32-bit ints
- I am not 100% sure, but I believe they cap at 4 billion (as opposed
to overflowing)
At any rate, just the process of trying to retain an object billions of
times is going to take a whole lot of CPU time, so it's probably best
to avoid it.
It *is* possible to make objects that can be released over and over
again without ever being freed. This might make your life easier. (I
think you override the class and make -retainCount return UINT_MAX.)
On Apr 18, 2005, at 10:05 PM, Daniel Jalkut wrote:
This is an interesting question, but I think you need to ask yourself
a question. When you get to the point where you're clearly pushing the
limits of a system's design, maybe you be doing it another way?
I would be suspicious of any design that requires an object to be
retained by billions of other objects. Is it possible that your
"ownership" model is such that the billion objects can contain an
unretained reference instead of a retained one? If this is a
situation where objects need to "back-reference" container or owner
objects, then it often makes sense to make those references unretained
to avoid circular ownership problems.
It seems unlikely that a billion objects could all have a legitimate
claim of ownership over an object within one iteration of the run
loop. Maybe you can elaborate on your situation if you think it's
well warranted...
Daniel
On Apr 18, 2005, at 1:43 PM, Ivan S. Kourtev wrote:
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@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden