• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: what's an NSZone?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what's an NSZone?


  • Subject: Re: what's an NSZone?
  • From: Chris Kane <email@hidden>
  • Date: Sat, 16 Feb 2002 11:46:15 -0800

On Friday, February 15, 2002, at 02:46 PM, Timothy J. Wood wrote:
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.

It was NeXT that had that thought.


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.

In OS releases post 10.1, they have been made interchangeable, as in this implementation of the NSZoneMalloc() function:

void *NSZoneMalloc(NSZone *zone, unsigned size) {
if (NULL == zone) zone = (NSZone *)malloc_default_zone();
return malloc_zone_malloc((malloc_zone_t *)zone, size);
}

And it's still not a good idea to destroy a zone if any objects that aren't yours might have gotten hold of that zone to allocate themselves in. (Well, that sentence doesn't parse easily, but you probably understand.)

However, the OpenStep semantics for NSRecycleZone() remain, so it does nothing at all since there's no way to "merge" malloc_zones. You have to drop to the malloc_zone API to destroy one.


Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
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.

  • Follow-Ups:
    • Re: what's an NSZone?
      • From: "Timothy J. Wood" <email@hidden>
References: 
 >Re: what's an NSZone? (From: "Timothy J. Wood" <email@hidden>)

  • Prev by Date: Re: multible NSImages rotated in the same view
  • Next by Date: Re: what's an NSZone?
  • Previous by thread: Re: what's an NSZone?
  • Next by thread: Re: what's an NSZone?
  • Index(es):
    • Date
    • Thread