Re: Speed Traps
Re: Speed Traps
- Subject: Re: Speed Traps
- From: p3consulting <email@hidden>
- Date: Wed, 21 May 2003 10:57:35 +0200
>
De: Ben Dougall <email@hidden>
>
Date: Mer 21 mai 2003 03:21:59 Europe/Brussels
>
@: email@hidden
>
Objet: Rip : Speed Traps
>
>
>
in this thread several people mentioned:
>
>
>>> inline ref-counting
>
>
what exactly is it? is there something i can read up on anywhere about
>
this, does anyone know?
>
>
thanks.
>
Many answers regarding the various retain mechanisms discussed in this
thread are in the source files (NSObject.m; ...) of the GNUstep
project, available on SourceForge (there is also a version using a
garbage collector).
In the GNUstep implementation of inline ref-counting, the retainCount
is not an instance variable, but memory blocks are allocated with a
"few" bytes more and the pointer on the object returned to the caller
is INSIDE the allocated block, the retainCount being then at a negative
offset of it.
The extraBytes allocated seem to be calculated so that "id" remain
aligned on 16-bytes boundary (on the Mac). Theorically, the extraBytes
value may be different from one OS (or hardware best alignement) to
another... This also means that you could store other things in theses
extraBytes if you would like to (like a back pointer on the NSZone, a
coloring value for some algorithms, debugging info, - by adapting
extraBytes size to your needs you can do anything you want)
One of the key point to this implementation seems to be that - on a
given platform - the class->instance_size doesn't change in function of
the retain mechanism used.
----------------------------- <-- pointer on memory block as
returned by OS system calls
| retainCount | extraBytes allocated
| ... |
----------------------------- <-- id returned to caller
| isa | (isa still the FIRST class instance
variable !)
| class->instance_size |
| bytes allocated |
| ... |
-----------------------------
Again speed versus memory footprint...
Pascal Pochet
P3 Consulting
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.