Does Mac OS have a way to create an anonymous file mapping?
<p>In the UNIX world, the standard way to create a file mapping object backed by RAM or the pagefile rather than a disk file is to call <code>shm_open</code>.  This creates a memory mapping with a name, and returns a file handle that you can pass to <code>mmap</code>.</p>

<p>The problem is that it creates a name.  It would be nice if I could create an anonymous memory mapping.  This would solve two problems:</p>

<ol>
<li>It would avoid problems where two instances of the same program may stomp on each other's mapped files.</li>
<li>If the program crashes or otherwise suddenly terminates, it would not leave the shared memory object around.  Calling <code>shm_unlink</code> immediately after <code>shm_open</code> is one possibility, but this leaves a small window in which a sudden termination would leave the object around until the next reboot.</li>
</ol>

<p>In Linux, there is <code>memfd_create</code> to solve this problem.  Similarly, Windows allows passing a null name to <code>CreateFileMappingW</code> to create an anonymous mapping.</p>

<p>Is there an equivalent for Mac OS?</p>