1

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?

Adrian Yu
  • 84
  • 1
  • 5

1 Answers1

0

That is using a memory-mapped file as the backing of the shared memory, so a physical file is necessary on disk on either machine. The OS still does extensive caching of the contents of that file, so it may still actually be able to keep it cached entirely in RAM if space is available.

If you don't like looking at a filename physically existing on disk, then you can try windows_shared_memory instead. It will use space taken from the system swap file as the backing of the shared memory instead.

bovine
  • 5,303
  • 2
  • 18
  • 17
  • But why does it behave differently between Win 7 and Server 08? On Server 08, there is no such physical file. – Adrian Yu Jun 22 '13 at 03:17
  • I haven't actually used `shared_memory_object` on Win32, so I can't confirm the difference in behavior.. . However, if you are not specifying an absolute path in the filename supplied to shared_memory_object then it's possible that a file getting created on Server 08 but it is just located in an unexpected directory. You could also use SysInternals' Process Explorer to see if it might actually have an unexpected open file handle someplace. – bovine Jun 26 '13 at 00:18