[shmem] leaving shared objects in memory
Hello! Can anybody tell me how can I make the shared memory segment (together with the objects constructed in it) remain in memory AFTER the process which created it terminates? E.g. Proc1 creates the segment and the objects in it. Proc2 accesses the segment and operates on the shared objects. Proc1 might get killed and I don't want this event to affect in any way Proc2. Thanks and regards, Szilard
Hi,
Can anybody tell me how can I make the shared memory segment (together with the objects constructed in it) remain in memory AFTER the process which created it terminates?
Sadly, Shmem is based on Windows shared memory lifetime, that is, process-lifetime. With this lifetime, when the last process attached to a shared memory is detaches the memory, the shared memory is destroyed. There is chance to maintain the memory in Shmem. On the other hand, Boost.Interprocess, the official Boost library based on Shmem, has changed shared memory lifetime to POSIX lifetime (kernel or filesystem) so you must explicitly destroy the shared memory (using shared_memory_object::unlink()). So you can use Boost.Interprocess to achieve shared memory persistence. Current Boost.Interprocess snapshot is in Boost CVS and Boost.Vault/Concurrent Programming. It has several changes requested in Shmem review, but in general it should be easy to port your application to Boost.Interprocess. Regards, Ion
participants (2)
-
Ion Gaztañaga
-
Pataki Szilard