Monday, February 3, 2014

Cleaning up a shared memory segment which won't go away with ipcrm

 http://ezaix.blogspot.in/2008/01/cleaning-up-shared-memory-segment-which.html

I have seen this happening when we run DB2 on AIX. Sometimes a stopped instance won't release the shared memory segment, not even with ipcrm. Here's what can be done under this situation:

1) Use the new -S option on ipcs to obtain the shared memory segment ID.
# ipcs -mS
m 131075 0x00001a4c --rw------- root system
SID :
0x2b85
2) Verify that the svmon command is installed on the system. If not,
install from the AIX installation CDs.
$ lslpp -l perfagent.tools

3) Use the svmon command to find all processes attached to the shared
memory segment.
# svmon -S 0x2b85 -l

Vsid Esid Type Description LPage Inuse Pin Pgsp Virtual
2b85 3 work shared memory segment - 656 0 0 656
pid(s)=10862

This shared memory segment has only one process attached.

To remove this shared memory segment, you must first kill the process that is attached to the segment.
# kill 10862
# ipcrm -m 131075

Memory utilisation of processes in AIX


For memory information, we use the command svmon.
svmon shows the total usage of physical and paging memory.

Command to display top ten processes and users
svmon -P -v -t 10 | more

Displaying top CPU_consuming processes:
ps aux | head -1; ps aux | sort -rn +2
Displaying top memory-consuming processes:
ps aux | head -1; ps aux | sort -rn +3 | head

Displaying process in order of priority:
ps -eakl | sort -n +6 | head

Displaying the process in order of time
ps vx | head -1;ps vx | grep -v PID | sort -rn +3

Displaying the process in order of real memory use
ps vx | head -1; ps vx | grep -v PID | sort -rn +6

Displaying the process in order of I/O
ps vx | head -1; ps vx | grep -v PID | sort -rn +4