Wednesday, April 30, 2008

Interesting OS X observation from Firefox development

OS X has memory issues, and APIs that don't do anything ...
Firefox 3 Memory Usage pavlov.net:

... On Mac, If you look at Activity Monitor it will look like we’re using more memory than we actually are. Mac OS X has a similar, but different, problem to Windows XP. After extensive testing and confirmation from Apple employees we realized that there was no way for an allocator to give unused pages of memory back while keeping the address range reserved.. (You can unmap them and remap them, but that causes some race conditions and isn’t as performant.) There are APIs that claim to do it (both madvise() and msync()) but they don’t actually do anything. It does appear that pages mapped in that haven’t been written to won’t be accounted for in memory stats, but you’ve written to them they’re going to show as taking up space until you unmap them. Since allocators will reuse space, you generally won’t have that many pages mapped in that haven’t been written to. Our application can and will reuse the free pages, so you should see Firefox hit a peak number and generally not grow a lot higher than that....
My sense is that OS X does a lot to test the patience of application developers.

I've been using Firefox 3 beta 5 on OS X, and I feel that it's faster and much less likely to peg my CPU.

No comments: