share memory on linux

how to list the orphaned shared memory?
how to kill them so that shared mem is free again.

thanks

Use the ipcrm -m command to free the orphaned shared memory, once you identify it

/proc/<process id>/maps or /proc/<process id>/smaps

try man 5 proc to see which one your system has and how to use it, to see if it meets your needs. I'm personally not too sure about finding orphaned memory.
Why do you think there is a problem? Are you sure it isn't some kind of memory leak?

ipcs shows your sysv ipc id's, etc..Otherwise as Jim noted.

If I understand correctly: We all have this problem when testing code sometimes.
Without a signal handler that cleans up the allocated shared memory segment
on a user interrupt you are stuck with manually removing the segment.

This is especially painful when the id is hardcoded and IPC_EXCL is specified or when you run into a sysv ipc limit maximum.

thanks for the replies.

ipcrm -m must be followed by shmid. how to get this id?

Also, I tried to set "kernel.shmseg" to 10 in /etc/sysctl.conf:

/sbin/sysctl -p
...
error: "kernel.shmseg" is an unknown key

Any idea how to set the kernel.shmseg?

I am using RHEL 4.
thanks

Umm..by ipcs output?

A typical listing looks like:

0x00000000 2112782337 username  666        4          0

Identification shouldn't be difficult. If it is (and I'm sorry if I make people mad) you shouldn't be using sys v ipc.

thanks.

do you know what is the equivalent of kernel.shmseg for Redhat Linux Enterprise 4?
tx

sysctl -a 2>/dev/null | grep shm

thanks

I only have these 3 parameters:

kernel.shmall
kernel.shmmax
kernel.shmmni

So SHMSEG is outdated in Enteprise Edition? does it have an equivalent?

thanks

My fault. You can find proximate settings under /proc/sys/kernel/shm*.
ipcs -lm to see your settings.