1

I'm using shared memory mapped with mmap to transfer quite large blocks between 3 processes, which works exactly as I want it to on Win(with different API, obviusly), however I'm having significant problem on Mac - after munmap() and shm_unlink() regardless of my attempts to avoid that os writes huge chunks on HDD and thus does not deallocate them immediatelly. So it works terribly slow instead of instant deallocation and it's possible to run out of 32 bit memory when transfering few chunks in a row.

Is it possible to simply drop shared memory allocated with mmap?

DeSt
  • 11
  • 1

2 Answers2

1

Did you try to share memory using boost interprocess library ?

It is designed to avoid portability problems by using the best suited implementation on every platform...

Johan
  • 3,728
  • 16
  • 25
0

This doesn't answer your question about dropping shared memory allocated with mmap without any disk operations.

However, if all your data fits in RAM, on Linux you can create a tmpfs (which is a directory that keeps everything in RAM) and do your work there, eg. by adding the following to /etc/fstab: tmpfs /mnt/tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=16000m 0 2. On Mac perhaps you can do something like that.

étale-cohomology
  • 2,098
  • 2
  • 28
  • 33