Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Chirone

macrumors 6502
Original poster
Mar 2, 2009
279
0
NZ
just wondering when you would use this method over just your normal alloc

i saw the method being used in some of apples sample code related to NSMenu
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
When physical locality in memory for different objects matters. This is probably rare in practice, but if you have a long-running program, it may be important to keep things close together to avoid swapping with closely-related objects. If these objects are far apart physically in memory it may require swapping to access both of them close together temporally.

-Lee
 

Chirone

macrumors 6502
Original poster
Mar 2, 2009
279
0
NZ
So it's for performance reasons then...

would you suggest it be used for menus?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I could imagine it being useful for menus, as they will be used together and stick around for the life of your program. I'd keep it simple for now, but if one were to use this, menus might be a good place.

-Lee
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
Zones appear to be largely non-useful. This is what CocoaDev has to say about them. The biggest drawback to zones is that you cannot apparently set the default zone, and if you use allocWithZone on an object that creates other objects, most or all of those other objects will almost certainly be allocated in the default zone.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.