Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange behaviour of mmap() in OS X



[cross-posted from maxos-x-dev to darwin-dev]

On Saturday, June 21, 2003, at 02:29 Uhr, Alexander Oberdvrster wrote:

mmap() seems to allocate and retain memory very aggressively in OS X.

Yes. I filed a bug on that exact behavior about 2 years ago. Maybe you should file one as well.

When I mmap() a large file (~200 MB in size) read-only and access it sequentially from start to end, the RSIZE of my program quickly grows to the size of the file. If the free physical memory is insufficient to accomodate the whole file, the system starts swapping heavily: first other data is paged out (running applications etc), then (after my application has finished and when the paged-out applications are needed again) it has to be swapped back in. During this time, the system is very unresponsive. The whole process can take several minutes.

Yup. In fact, I managed to completely lock up my test system with about 4-5 iterations of such a test. It is really completely unacceptable behavior for a modern VM implementation. In effect, you are in the same situation as if you didn't have virtual memory. Ridiculous.

Has anyone else observed this behaviour? Is there a workaround? (besides the obvious 'don't use memory mapped files')

Well, there are some system calls that *should* help, but the last I checked they didn't (and weren't even hooked up properly, see xnu). This may have changed in the meantime.

Note that other UNIXes I tested (Linux, IRIX) seem to handle mmap() more gracefully and the system remains fully usable during and after the mmap(). The amount of swapping is minimal.

There shouldn't really be any swap-out at all.

This was not due to the amount of free memory: The Linux box has about 256 MB RAM with ca. 150 MB free, the IRIX machine has only 64 MB with ca. 30 MB free. The Mac (a PowerBook 12") has 640 MB RAM, 180 MB were unused (inactive). All data was gathered with 'top'.

I know that I can give the VM manager hints about the memory usage (I use it sequentially), but memadvise() seems to be broken in OS X. I have this impression from previous posts to several mailing lists and my own experience.

Yup.

The OS version is 10.2.6.

Well, that kills the theory that matters might have improved in the meantime.

Marcel

--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
1d480c25f397c4786386135f8e8938e4
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.