I use memory between the parent process and several child processes, allocating shared memory segments using shm_open / mmap in OS X. Any parent or children can create a segment and then report an identifying name. I understand that a parent must call shm_unlink on each of these segments when it finishes working in memory cleanup, otherwise shared memory is constantly leaking out.
What I initially thought after reading the documentation is that shared segments are cleared when no processes are displayed with it. However, experiments show that this is not the case, and someone should explicitly use shm_unlink.
Is there any way in OS X to list all existing shared memory segments? The problem is that the parent may crash and therefore has no chance to call shm_unlink. On Linux, my solution is to clear / dev / shm, but on OS X, I need some way to publish open shared segments.
source share