Operating System - HP-UX
1825775 Members
2307 Online
109687 Solutions
New Discussion

Lost Shared Memory Segments

 
SOLVED
Go to solution
Alex Green
Frequent Advisor

Lost Shared Memory Segments

Hi All,

I just wanted to ask all here, if anyone had some good suggestions as how to go about recovering lost shared memory segments. i.e. segments that we allocated and then not returned by an application. Thanks, if more detail is need, I can supply it.
"The physicist's greatest tool is his wastebasket." - Albert Einstein.
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: Lost Shared Memory Segments

Hi:

I'm not sure that I understand your question. Did you set these up as IPC_PRIVATE? You might use ftok to set up a key and then recovery becomes simple. If you will post just a bit of the code or outline the process better, I or someone else can probably help more.
If it ain't broke, I can fix that.
Bill Hassell
Honored Contributor
Solution

Re: Lost Shared Memory Segments

Start with:

ipcs -bmop

Look for NATTCH = 0 and determine if that segment is no longer necessary. Then use ipcrm to remove that segment.

To get a better picture of shared memory, get a copy of shminfo from:

ftp://contrib:9unsupp8@hprc.external.hp.com/sysadmin/programs/shminfo

You'll also get a copy of a simple program to test shared memory allocation.


Bill Hassell, sysadmin
A. Clay Stephenson
Acclaimed Contributor

Re: Lost Shared Memory Segments

Hi:

I will add that NATTACH = 0 is a necessary but not always sufficient condition to detach a shared memory segment. It may be that a process created the segment for a group of processes to utilize. Just because no processes have it attached at the moment does not mean that it is always safe to remove. A critical process could die or fail to start if it could not find the segment. I was reluctant to mention ipcrm until I knew a few more details. As usual with things UNIX, the answer is it depends.

I will certainly concede that most of the time the NATTACH = 0 condition indicates that it is okay to blow this guy away.

Regards, Clay
If it ain't broke, I can fix that.