Re: Shared Memory and login sessions
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com -- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Feb 7, 2008, at 3:23 PM, Andy Klepack wrote: I’m curious whether there is any guarantee that leaked shared memory is reclaimed when a user logs out. If a region is opened via shm_open but not closed before the user logs out, is that memory reclaimed by the OS or does it persist until reboot? My suspicion is that it is not reclaimed since there is no assurance that the sharing processes are all running in the user’s session, but a definitive answer would be great. It is a persistent object, so unless you explicitly destroy it, it will effectively persist forever (or until the next reboot, or until the segment is explicitly deleted by another process). There is lots of documentation on how to implement shared memory using System V shared memory, POSIX shared memory (which is what you are talking about when you talk about shm_open), and mmap(). I typically suggest using mmap(), since there are no resource tracking cleanup issues with mmap(), as there are with the others. You can also hand around memory maps between processes using Mach primitives, which will be resource tracked and cleaned up when the last reference goes away. Which method you choose really depends on whether or not your process is intended to be runnning all the time, and if so, whether it is intended to resynchronize or delete and recreate the mapping when it restarts. Typicially, people who choose to go the POSIX shared memory (shm_open) route register atexit() handlers and signal handlers so that if the process dies, it will clean up after itself. Otherwise they pick some other method of sharing memory. This email sent to site_archiver@lists.apple.com
participants (1)
-
Terry Lambert