in reply to anyone have some good mmap examples?

The simplest example would simply be a large read-only data file that needs to be accessed by multiple processes. For speed, you want each process to have it in memory rather than hitting disk all the time. However, you don't want to waste memory giving each process a copy. So, you mmap it and everyone can see it, and have fast access, but you only use the memory once.
  • Comment on Re: anyone have some good mmap examples?

Replies are listed 'Best First'.
Re^2: anyone have some good mmap examples?
by zentara (Cardinal) on Dec 15, 2004 at 09:18 UTC
    Now, why couldn't they have just said that in the docs? :-)

    I'm not really a human, but I play one on earth. flash japh
      Because there's lots of more complicated uses too. For example, maybe the data isn't read-only. Then you need to consider how to handle writes. Or it might not be a simple data file. For example, I know an application that uses finite automaton data structures that weigh in a hundreds of MB. The whole data structure is dumped to disk for storage between runs. When the data structure is loaded into the applications it uses an mmapped region.