1833325 Members
3066 Online
110051 Solutions
New Discussion

Re: process size

 
SOLVED
Go to solution
Shivkumar
Super Advisor

process size

what is command line option with $ps command to view process size of a particular process.

Thanks,
Shiv
14 REPLIES 14
Simon Hargrave
Honored Contributor

Re: process size

UNIX95= ps -e -o pid,vsz,args

The UNIX95= before is important, so it uses the XPG4 syntax of the command. Of course you can add more fields, I just added vsz (virtual set size), process ID and command.
Alex Lavrov.
Honored Contributor

Re: process size

export UNIX95=1
ps -o sz | grep


"man ps" for more options. There are lot of stuff you can see with ps when XPG64 support is enabled (UNIX95=1)

Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Mel Burslan
Honored Contributor

Re: process size

Here, I must agree with Simon's solution, i.e.,

UNIX95= ps -e -o pid,vsz,args

as exporting UNIX95 variable may have some unexpected effects on processing of other commands in the same interactive session. Let it do its job for one command and die.

________________________________
UNIX because I majored in cryptology...
Shivkumar
Super Advisor

Re: process size

What XPG64 and vsz in the output stands for ?
Shivkumar
Super Advisor

Re: process size

is "vsz" means RAM memory size ?
RAC_1
Honored Contributor

Re: process size

vsz - virtual segment size. for details man ps

XPG4 is a standard. Use of UNIX95 enforces the ps command conformance to XPG4.
There is no substitute to HARDWORK
Tim Nelson
Honored Contributor

Re: process size

ps -lf

SZ
The size in physical pages of the core image of
the process, including text, data, and stack
space. Physical page size is defined by
_SC_PAGE_SIZE in the header file (see
sysconf(2) and unistd(5)).
Torsten.
Acclaimed Contributor
Solution

Re: process size

As far as I know XPG stands for X/open Portability Guide + version - the applications environment.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Geoff Wild
Honored Contributor

Re: process size

And here's a little script for you:

# cat processmem
#!/bin/sh
# processmem - display memory claimed by a process
# gwild 03192004
#
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.
Bill Hassell
Honored Contributor

Re: process size

The amount of memory used by a process in HP-UX is quite complex to determine. ps (with the optional UNIX95 setting) will report the virtual memory size in Kbytes, but this is not a clear picture at all. 99% of all processes use shared text which means that only one copy of the instructions are in RAM and all copies of the same process use this one area. There is a separate stack area plus a data area which are included in the vsz calculation.

But many processes, especially databases, use shared memory for rapid interprocess communication. Because it is shared, there is no accounting for this area in ps. You have to use ipcs -bmop to see the shared memory areas. And then there's the buffer cache which is shared by all processes that open files and read/write to them. And some processes may use memory mapped files...

Usually, you really don't need to know much more about RAM used by processes than supplied by ps, but it isn't a complete picture. To really see RAM usage, you need to purchase the Glance product.


Bill Hassell, sysadmin
Shivkumar
Super Advisor

Re: process size

Bill Hassell; Is there a way to know which processes are using shared memory on hpux 11/11i os ?

Also, can i find the memory leakage by observing increase in memory size in glance tool ?

best regards,
Shiv
Alex Lavrov.
Honored Contributor

Re: process size

To view shared memory information use command:
ipcs

To view memory segments: ipcs -m
To view semaphores: ipcs -s

You also will see he PID of the process. There are many other options to view what processes attached to these segments and when they did it. For more options you can use "man ipcs"

Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Rajesh SB
Esteemed Contributor

Re: process size

Hi,

The command "ipcs" displays information for the message queues, shared memory segments, and semaphores that are currently active in the system.

If you user # ipcs -a option shows in details about process thier ownership, size etc.

Regards,
RAjesh
Bill Hassell
Honored Contributor

Re: process size

Memory leaks are programming errors and you will see this as particular processes continue to grow in size when they aren't suppossed to do that. How can you tell? By asking the writer of the program whether their process is supposed to get bigger without bounds. I know that is often impossible to do but if you purchased applications from a vendor, you certainly can demand to know what the normal behavior is supposed to be.

There is no magic monitoring feature that says: Memory leak in process 1234. To see this, start be ignoring processes that do not use a lot of memort and sort the processes by size:

UNIX95= ps -e -o vsz,pid,ppid,ruser,args | sort -rn | head -20 >> /tmp/topramusers.log

Now run this command regularly and then check the file every day (or hour) to see what is changing. Most questions like this are related to error messages about program too bin or unable to allocate more memory. And very seldom is this a problem with a memory leak--it is a problem with 32bit programs and their memory addressing limitations.


Bill Hassell, sysadmin