On Fri, Feb 13, 2009 at 2:03 PM, Naveen Santhanam
Hello,
We have a windows application (a process) that requires a large data file (approx. 100 MB) to perform a task. We have a master that launches several instances of this application. We would like to share the large data file across the processes such that, there is just one instance of the data file in physical memory without any disc access. Hence each application will have a small footprint in memory during execution. We have tried using a managed shared memory object from the boost::interprocess library to achieve this. However, this doesn't help us as the memory footprint of the application goes up upon access of the data file. Is there a way to achieve the desired single footprint memory sharing? Does this work as expected with other OSes?
Just mapping the file to memory in windows will do what you want. Boost.Interprocess has a wrapper you can put around a section of memory that you have mapped, but you do not need it for this, just map it yourself and access it like normal memory. The Boost.Interprocess wrapper makes accessing it more consistent though, especially if you intend to port to other OSes as well.. The memory usage will be reported as much higher for each program, but that whole file of each app will be shared, regardless what the task manager reports.