Operating System - HP-UX
1833807 Members
4310 Online
110063 Solutions
New Discussion

Memory usage GlancePlus versus ps

 
Gordon_10
Occasional Contributor

Memory usage GlancePlus versus ps

Why does the memory usage of an application group in GlancePlus not equal the amount of memory shown in the size portion of a ps command? I would expect some variance but the numbers are off by mega bytes.
Strike while the iron is hot.
6 REPLIES 6
G. Vrijhoeven
Honored Contributor

Re: Memory usage GlancePlus versus ps

Gordon,

What kind of memory useage are you compairing? Note that memory usage reports are estimates and they "can" differ in time.

Gideon
Geoff Wild
Honored Contributor

Re: Memory usage GlancePlus versus ps

How are you getting the memory with ps?

I do it like:

#!/bin/ksh
# usermem - display memory claimed by a user
#
if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "usermem \"userid\""
echo "Example:"
echo "usermem gwild"
exit 1
fi
echo " "

USER=$1
t=0
for j in `UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid,args=Command-Line | sort -rnk1 | grep -v Kbytes | grep $USER | awk '{print $1}'`
do
t=`expr $t + $j`
done
echo "\nMemory claimed by $USER: $t 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.
Gordon_10
Occasional Contributor

Re: Memory usage GlancePlus versus ps

Close. I use the following:

#!/bin/ksh
mps=0
for sz in `ps -elf | grep $1 | grep -v grep | cut -c47-51`
do
mps=`expr $mps + $sz`
done
echo `expr $mps \* 4096`

And then pass in what I'm looking for:

$ mps.ksh rpc
1941504
$

This is the approximate size in bytes of all the rpc processes. In GlancePlus I know I'm looking at the wrong stuff because Virtual Memory and Res. Memory only come to (26680+9712)36392 somethings. Not sure what this is as page size does not work. So the question is what is GlancePlus showing me?
Strike while the iron is hot.
Geoff Wild
Honored Contributor

Re: Memory usage GlancePlus versus ps

I think it's your cut....

try this:

#!/bin/sh
mps=0
for sz in `ps -elf | grep $1 | grep -v grep | awk '{print $10}'`
do
mps=`expr $mps + $sz`
done
echo `expr $mps \* 4096`


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.
Gordon_10
Occasional Contributor

Re: Memory usage GlancePlus versus ps

Thanks. Looks like expr doesn't care for the spaces left over by the cut.
Strike while the iron is hot.
Geoff Wild
Honored Contributor

Re: Memory usage GlancePlus versus ps

Here's a modified version - using UNIX95:

#!/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"
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.