1

On Solaris, how can I find out how much swap space a given process is occupying? Or even better, how can I list all running processes sorted by swap space usage?

I'm asking this particulary for Solaris. I do not have the top command available and neither prstat nor swap seem to be able to provide information about how much swap space a given process is using.

dokaspar
  • 155
  • 1
  • 2
  • 8

3 Answers3

4

You can use the command:

pmap -S <pid>

to see all the memory statistics, including swap usage.

With little shell magic you can wrap it in a bash loop:

cd /proc
for i in *; do
    SWAP=`pmap -S $i | grep ^total | awk '{ print $3; }'`
    [ "xx$SWAP" != "xx" ] && echo "$SWAP bytes $i"
done | sort -n

Output is in bytes, in a format:

<number> bytes <pid>
Jakov Sosic
  • 5,157
  • 3
  • 22
  • 33
0

I'm not sure if $3 matches the column you want, because it's the "Kbytes" and not "Swap" column.

In the Header it's the 3rd but not in the grep total (because of the blank in "total Kb"):

Address  Kbytes    Swap Mode Mapped File

total Kb  240576  235028`
Uwe Keim
  • 2,370
  • 4
  • 29
  • 46
-1

for i in * ; do pmap -S $i 2> /dev/null | nawk -v PID=$i '$1 == "total" && $4 > 0 {print PID,"=>",$4,$2}' ; done |sort -rn -k 3,3