Re: Memory Mania Revisted
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.