Re: what's an NSZone?
Re: what's an NSZone?
- Subject: Re: what's an NSZone?
- From: "Timothy J. Wood" <email@hidden>
- Date: Fri, 15 Feb 2002 14:46:55 -0800
You could sort of think of a NSZone as an independent heap. Objects
allocated from the same zone should live one the same set of virtual
memory pages and thus if they are used near in time you can potentially
cause less paging. Likewise, if they are to be deallocated at the same
time you will cause less fragmentation (and thus less paging). There
are cases where this is useful, but apparently the thought at Apple is
that this isn't so useful anymore.
I say 'could' because this is what NSZone used to be -- NSZone has
been neutered in recent releases (i.e., anything post-NEXTSTEP :)
Rather than documenting that this isn't so useful anymore, they just
broke zones so that you cannot easily create a real NSZone anymore (the
zone creation call just creates a child zone of the main zone which
doesn't actually split up the allocations into different subsets of the
VM pages).
I find this interesting since Apple DOES use zones internally (in
particular, CoreGraphics creates a zone). If you look in
<objc/malloc.h> you will find something analogous to an NSZone, the
malloc_zone_t. While NSZone and malloc_zone_t do basically the same
sorts of things, they are not interchangable sadly.
It would be much nicer if Apple made NSZone and malloc_zone_t be the
same thing and actually allowed developers to build real zones. This is
very useful in some limited cases -- documentation should be used to
dissuade people from misuse, not by just taking away our toys.
I've been considering adding +allocWithMallocZone: as a category on
NSObject ... :)
-tim
On Friday, February 15, 2002, at 12:35 PM, Matt Neuburg wrote:
Lots of methods require an NSZone parameter. But NSZone isn't documented
anywhere. Sure, there's a header file, but it remains unclear how you'd
ever "say" a zone (other than to ask an existing object or class for
*its*
zone). It seems to me there's a piece of the documentation puzzle simply
missing. m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt
pantes gar anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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.
_______________________________________________
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.