We have a in-house application that uses mmap to pull a file into memory. I can't seem to find any info on where this file is stored in memory. I know that it is shared memory. But does the /dev/shm have anything to do with it. Isn't shm just a tmpfs? Also can shm be disabled? I have a machine with 16GB and 8GB then goes to the shm. Does this only allow mmap to use the other 8GB or is all 16GB accessible to it? These are the questions I have been trying to figure out for over a week now. Not many answers on google and no one has seemed to ask this before. Also is mmap the fastest way to get a file from disk to memory? Any help appreciated. Thank you, Brad Dameron SeaTab Software www.seatab.com
On Wed, 6 Jul 2005, Brad Dameron wrote:
We have a in-house application that uses mmap to pull a file into memory. I can't seem to find any info on where this file is stored in memory. I know that it is shared memory. But does the /dev/shm have anything to do with it. Isn't shm just a tmpfs? Also can shm be disabled? I have a machine with 16GB and 8GB then goes to the shm. Does this only allow mmap to use the other 8GB or is all 16GB accessible to it? These are the questions I have been trying to figure out for over a week now. Not many answers on google and no one has seemed to ask this before.
Also is mmap the fastest way to get a file from disk to memory?
1. memory mapped files will not show up in, nor do they have anything to do with, /dev/shm. 2. I don't know if /dev/shm can be disabled or anything much at all about it. 3. You can mmap some pretty beefy files, bigger than physical RAM, certainly (provided you don't have a truly scandelous amoung of RAM). 4. a memory mapped file is almost entirely "free" in terms of actual memory usage *until* you start accessing it, at which point how much memory it uses becomes a very complicated question to answer, depending on the access pattern and memory pressure. 5. sometimes mmap is and sometimes it isn't the fastest way to get a file from disk to memory. Size, among other things, has alot to do with it. If the size of the file is less than a couple of pages (pages are usually 4K), then usually reading it into a memory buffer is faster. Somewhere, and I'm sure this varies with the phase of the moon, there is a cutoff, however, there is no definitive answer here, although one can guess that it's in the low single-digits worth of pages. -- Carpe diem - Seize the day. Carp in denim - There's a fish in my pants! Jon Nelson <jnelson-suse@jamponi.net>
participants (2)
-
Brad Dameron
-
Jon Nelson