mmap and memory usage
807567Nov 22 2004 — edited Jan 11 2005I hope I found the right forum. The search on mmap related entries indicates that all was raised in this forum. Unfortunatly none answered my question...
My knowledge of the Solaris memory management is limited. I have just found and read the white paper "The SOlaris Memory System", Sizing, Tools and Architecture", but didn't find the answer to my question.
I work on a Solaris 8 system with 40+ servers and around the same number of clients. These uses mmap to share a persistent object storage file. This file can be rather large (40MB).
At some point we cannot start new applications, they fail reporting a mmap EAGAIN problem ("Resource temporarily unavaliable"). All documentation I read indicates that this means that the system is out of memory.
Looking with the "standard" memory tools, I cannot see that the memory should be exchausted (Often over 200 MB memory is reported free and 500 MB swap). The machines have 2 GB.
However all indications are that the applications really runs out of memory; Changing the mmap'ed files size to for example 1/2 the size, more applications can start before failing.
I understand the mmap functions purpose and usage, but I don't understand its memory usage;
* Will it take the amount of memory mmap'ed for each application? The documentation is rather ambigious on this. I would have thourght that the memory was shared and therefore allocated once and used by all applications. The man pages under "usage" indicates that the mmap will affect the available memory, but not how. Is it for 10 applications mmap'ing a 40MB file 400MB? Or only 40MB? Or something in between?
* I understand that the mmap'ed memory must be allocated in one "chunk". Can my problem be that the system cannot find 40 MB of free memory in one chunk?
* mmap seems to be often compared/discussed together with malloc and other memory allocation operations. What is the difference? One description says that mmap'ed memory can be reused while the application performing the mmap is still running. What does that mean?
* Are there any tools that can help me get a better oberview of what goes wrong (I found a description of some RMC memory tools, but they seem to be avaliable only on direct request).
* What have I overseen?