• 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: Memory Mania Revisted
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Mania Revisted


  • Subject: Re: Memory Mania Revisted
  • From: email@hidden
  • Date: Tue, 12 Feb 2002 11:58:21 -0800

Why zones are thought to be less efficient? I am using them in a way I
was using them before, and although the performance gain is not so
dramatic as before (OpenStep), I still see many cases where they make
significant difference...

Hmm. I believe the rationale I heard (from the coder of the OS X malloc implementation) was this. The most important factor in memory allocation performance in OS X is minimizing the total number of pages of memory active at any given time. (This is on a typical end user machine where memory is sufficiently limited that swapping is occurring as part of normal operation). The number of pages you have active is roughly related to your high water mark -- you may be able to swap out less active pages from time to time, but each time you return to your high water mark those pages will get swapped back in. The more pages your high water mark consists of, the more swapping you do. With a single zone, malloc can use free blocks for any purpose asked of it, so your app gets a "combined high water mark" based upon memory allocation patterns for the entire app. As soon as you split into two zones, each of those zones has its own high water mark, and even if they don't occur at the same time (if one zone's high mark corresponds to the other zone's low mark), your application's performance will essentially behave as if the total high water mark is the sum of the high water marks of the two zones, because free blocks in one zone cannot be used for allocations in the other zone. The more zones you split off, the higher your combined high water mark becomes, as a result of this effect. So you swap more, and performance goes down.
There are doubtless cases where using zones pays off. The assertion is that those cases are rare, and that it is rarely worthwhile to cater to them -- it will increase the development effort and maintenance problems for your app, and that effort would probably produce greater gains in performance with fewer disadvantages if spent doing optimization work elsewhere.

All this said, I'm not going to try to defend any of this further; I'm simply repeating what I was told by someone who knows a great deal more about memory issues on OS X than I do. I personally never use zones in my coding; your mileage may vary.

Ben Haller
Stick Software
_______________________________________________
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.

  • Prev by Date: Switching resolution and positioning the window
  • Next by Date: Re: about help
  • Previous by thread: Re: Memory Mania Revisted
  • Next by thread: Drag and Drop: Carbon to Cocoa?
  • Index(es):
    • Date
    • Thread