Boost logo

Boost Users :

Subject: Re: [Boost-users] [interprocess]shared_memory_object stores content in disk?
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2013-06-24 15:32:38


El 20/06/2013 7:44, Adrian Yu escribió:
> I'm training multiple networks based on a single database.
>
> So to accelerate speed and reduce disk reading, I use
> shared_memory_object class provided by boost. Since the lab
> workstation is currently unavailable, I migrated my code to my
> personal computer.
>
> On the lab workstation, the host program successfully reads all data
> to memory. But on my PC, strangely it creates a file on system drive
> rather than storing the data in memory. The whole database is about
> 3.7 GB; the lab workstation has 32 GB memory and runs Windows Server
> 2008 R2; my PC has 8 GB memory and runs Windows 7.
>
> There should be enough memory to store the data. So why? Are there
> certain ways to force the program to keep all data in memory?

In windows, Interprocess emulates POSIX-like shared memory semantics
using a file (in the server and in your workstation) instead of the
native windows shared memory. However, creating this file is not very
different from the native shared memory since Windows must allocate
enough space in the paging file to store the whole segment in case other
memory requests require dumping the shared memory to the paging file to
free phyisical memory for other uses. So, you always need disk-based
backup space for shared memory. If there is enough free memory in the
system the OS will try to avoid writing to file, just like with native
shared memory.

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net