FROM : Shaun Wexler
DATE : Tue Apr 19 21:05:59 2005
On Apr 19, 2005, at 8:45 AM, John Stiles wrote:
> 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).
Actually, the smallest objects are just 4 bytes , with an implied
1 reference. Foundation adds the object's id to an "extra ref count"
maptable to add any additional ref's, which is why retain/release is so
expensive, thus inline refcounts are preferred for performance reasons.
Apple's malloc implementation is guaranteed to return buffers as
multiples of 16-bytes, vec-aligned, so all objects are at least 16
bytes, thus you always have 3 extra int's or floats to play with.
FWIW, my base framework creates all cache-aligned/sized objects with a
noticeable performance increase, as well as atomicity benefits that
facilitates known ivar alignments and access grouping.
> 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)
Most CF container classes use a long long (64 bit) inline ref count,
and many AppKit classes use a shorter-than-32-bit inline ref count,
with a designated bit for "refCountOverMax" that (assuming) either
leaks the object or defers to the default/super refcount for the
overage.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
DATE : Tue Apr 19 21:05:59 2005
On Apr 19, 2005, at 8:45 AM, John Stiles wrote:
> 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).
Actually, the smallest objects are just 4 bytes , with an implied
1 reference. Foundation adds the object's id to an "extra ref count"
maptable to add any additional ref's, which is why retain/release is so
expensive, thus inline refcounts are preferred for performance reasons.
Apple's malloc implementation is guaranteed to return buffers as
multiples of 16-bytes, vec-aligned, so all objects are at least 16
bytes, thus you always have 3 extra int's or floats to play with.
FWIW, my base framework creates all cache-aligned/sized objects with a
noticeable performance increase, as well as atomicity benefits that
facilitates known ivar alignments and access grouping.
> 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)
Most CF container classes use a long long (64 bit) inline ref count,
and many AppKit classes use a shorter-than-32-bit inline ref count,
with a designated bit for "refCountOverMax" that (assuming) either
leaks the object or defers to the default/super refcount for the
overage.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
| Related mails | Author | Date |
|---|---|---|
| Ivan S. Kourtev | Apr 18, 22:43 | |
| Daniel Jalkut | Apr 19, 07:05 | |
| John Stiles | Apr 19, 17:45 | |
| j o a r | Apr 19, 18:19 | |
| Axel Andersson | Apr 19, 18:44 | |
| Ali Ozer | Apr 19, 18:46 | |
| Ondra Cada | Apr 19, 18:57 | |
| Ivan S. Kourtev | Apr 19, 20:30 | |
| Ondra Cada | Apr 19, 20:55 | |
| Shaun Wexler | Apr 19, 21:05 | |
| Shaun Wexler | Apr 19, 21:09 | |
| Scott Ribe | Apr 23, 00:25 | |
| Bob Ippolito | Apr 23, 00:40 | |
| Scott Ribe | Apr 23, 00:51 | |
| Bob Ippolito | Apr 23, 06:57 | |
| Johnny Deadman | Apr 23, 18:44 |






Cocoa mail archive

