1824936 Members
3884 Online
109678 Solutions
New Discussion юеВ

process memory usage

 
SOLVED
Go to solution
Lorenzo Santacana
Occasional Contributor

process memory usage

Hi all,

I want to check if a process has memory leaks so I need to monitor the memory usage of the process. Which is the command to check this? Using thye command "top" sometimes my process is not shown in the list.

Many thanks,
Lorenzo
5 REPLIES 5
Scot Bean
Honored Contributor

Re: process memory usage

If you have glance, start it with "gpm" and you can monitor your individual application.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: process memory usage

For a single process for which you know the process id (PID), do something like this in a loop.

UNIX95= ps -p PID -o vsz,comm

Note the space after UNIX95=. This asserts the XPG4 behavior in ps. Vsz displays the size of the process in KB.

Man ps for details.
If it ain't broke, I can fix that.
Sridhar Bhaskarla
Honored Contributor

Re: process memory usage

Hi Lorenzo,

Run

UNIX95= ps -e -o 'vsz pid args' |sort -n

periodically and check the processes whose vsz (first column) values are increasing over the time. They are most likely (not necessarily) the candidates of memory leaks. You will need to work with the vendor/developers to find the reason why the vsz is increasing over the time.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Geoff Wild
Honored Contributor

Re: process memory usage

Here's a little script for you:

# cat processmem
#!/bin/sh
# processmem - display memory claimed by a process
#
if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "processmem \"process\""
echo "Example:"
echo "processmem rpc"
exit 1
fi
echo " "

PROCESS=$1

mps=0
#for sz in `ps -elf | grep $PROCESS | grep -v grep | awk '{print $10}'`
for sz in `UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid,args=Command-Line | sort -rnk1 | grep -v Kbytes | grep $PROCESS | awk '{print $1}'`
do
mps=`expr $mps + $sz`
done
#echo `expr $mps \* 4096`
echo "\nMemory claimed by $PROCESS: $mps Kbytes.\n"


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Con O'Kelly
Honored Contributor

Re: process memory usage

Hi Lorenzo

There is also a utility called 'procsize' which is excellent for showing memory breakdown for each process. Use as follows:

# procsize -fnc | sort -rnk 11

I have attahced the binary.

It is available for download from:
ftp://eh:spear9@hprc.external.hp.com/procsize

Cheers
Con