Note that there are some explanatory texts on larger screens.

plurals
  1. POReserving Shared Memory with No File Backing (Linux/Windows) (boost::interprocess)
    primarykey
    data
    text
    <p>How can I reserve and allocate shared memory <em>without</em> the the backing of a file? I'm trying to reserve a large (many tens of GiBs) chunk of shared memory and use it in multiple processes as a form of IPC. However, most of this chunk won't be touched at all (the access will be really sparse; maybe a few hundred megabytes throughout the life of the processes) and I don't care about the data when the applications end.</p> <p>So preferably, the method to do this should have the following properties:</p> <ol> <li>Doesn't commit the whole range. I will choose which parts to commit (actually use.) (But the pattern is quite unpredictable.)</li> <li>Doesn't need a memory-mapped file or anything like that. I don't need to preserve the data.</li> <li>Lets me access the memory area from multiple processes (I'll handle the locking explicitly.)</li> <li>Works in both Linux and Windows (obviously a 64-bit OS is needed.)</li> <li>Actually uses shared memory. I need the performance.</li> <li>(<strong>NEW</strong>) The OS or the library doesn't try to initialize the reserved region (to zero or whatever.) This is obviously impractical and unnecessary.</li> </ol> <p>I've been experimenting with boost::interprocess::shared_memory_object, but that causes a large file to be created on the filesystem (with the same size as my mapped memory region.) It does remove the file afterwards, but that hardly helps.</p> <p>Any help/advice/pointers/reference is appreciated.</p> <p>P.S. I do know how to do this on Windows using the native API. And POSIX seems to have the same functionality (only with a cleaner interface!) I'm looking for a cross-platform way here.</p> <p><strong>UPDATE:</strong> I did a bit of digging, and it turns out that the support that I thought existed in Windows was only a special case of memory-mapped files, using the system page file as a backing. (I'd never noticed it before because I had used at most a few megabytes of shared memory in the past projects.)</p> <p>Also, I have a new requirement now (the number 6 above.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload