c++ - Unexplained Linux System V IPC shared memory segment marked for destruction -


I have a Linux system V IPC shared memory segment which is populated by a process and is read by many others . All process interfaces use up to the shared memory segment as a class, which takes care to view, attach and separate segments as part of their Constructor / Destructor methods.

The problem here is that from time to time, I see that "division" is in the segment. What do I mean by looking at the "IPCS-M-S" output, I think I have listed two segments Are: The one who has been marked for destruction, but he also has some procedures, and another such that to achieve all the new efforts to engage the Segment. However, I'm not really telling the kernel to destroy the segment. What's going on here?!

Another thing to note is that unfortunately running on this system is seriously redundant in the memory department, it has a physical memory of 1 GB, no swap, and / proc / meminfo Committed_AS is reporting about 2.5 GB of free memory. Fortunately, system processes are not actually using this memory ... they are just asking for it (I still have approximately 660 MB of free "memory as reported by vmstat). Although I know that it is far from ideal, because there is nothing for time, what can I do about exaggerated memory, although browsing the kernel / libc source I do not see anything there that users For any reason other than the request marks the shared memory segment (but perhaps I have hidden it somewhere).

Here is the shared Memory Interface class constructor for reference:

  const char * shm_ftok_pathname = "/ usr / bin"; Int shm_ftok_proj_id = 21; // Creates a key from the file path, so different processes will get the same key key_t m_shm_key = ftok (shm_ftok_pathname, shm_ftok_proj_id); If (m_shm_key == -1) {fprintf (stderr, "shared memory \ n% s \ n", can not obtain the key for strerror (errno)); Exit (status); } M_shm_id = shmget (m_shm_key, sizeof (shm_data_s), (IPCCRAT | 0666)); If (m_shm_id & lt; 0) {fprintf (stderr, "The shared memory ID could not be found \ nerrno =% s \ n", strerror (errno)); Exit (status); } // Get a PTR for the shared memory, which is the second argument of a shared memstrat / 0, say OS shipped the OS address m_shm_data_ptr = (shm_data_s *) shmat (m_shm_id, 0, 0); If ((int) m_shm_data_ptr == -1) {fprintf (stderr, "Could not get shared memory pointer \ n"); Exit (status); }  

And here's my only output: Linux 2.6.18-5-686 # 1 SMP Fri Jun 1 00:47:00 UTC 2007 i686 gnu / linux

My first guess is that you are probably calling shmctl (..., IPC_RMID, ...)

Can you show the Shared Memory Interface Class Destructor?


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -