Operating System - HP-UX
1827811 Members
2172 Online
109969 Solutions
New Discussion

Memory Utilization check using ps

 
SOLVED
Go to solution
Conal O'Kelly
Advisor

Memory Utilization check using ps

Hi All
A question on memory utilisation. I have used the following command to sort the top memory processes on the system.
export UNIX95=1 ; ps -el -o pid -o sz -o vsz -o comm| grep -i -v "pid" | sort -nr -k 2,2.

I have a couple of questions related to this:
1. Am I correct to assume that the if I multiply the the sz field by 4 & divide by 1024 this gives me the size of the process resident in memory in MB (it seems to equate roughly to RSS field in glance ).

2. I have also totalled this column (sz) and the figure is 3843. My system only has 3GB of memory. I thought resident in memory meant it was currently loaded into memory?

3. Finally what is the difference between sz & vsz fields in ps listing. Do these columns relate to RSS/VSS in glance or RES & SIZE in top.

Thanks for any help.

Cheers
Con



5 REPLIES 5
Stefan Farrelly
Honored Contributor

Re: Memory Utilization check using ps


The RES field from ps does indeed show memory used/utilised but it does NOT show shareable memory. ie. multiple copies of the same program running - their instruction code will all be shareable - but ps will show them all in the RES field for each copy, which means you cant use the RES field from ps to work out memory usage - it just wont add up - as youve found out.

For proper memory usage you really need to use glance/gpm - you can get a free trial to run it when you install if for the first time.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Conal O'Kelly
Advisor

Re: Memory Utilization check using ps

Hi
Thanks alot for your help. Im a bit clearer now on what the sz field is showing in ps.

Cheers
Con
Bill Hassell
Honored Contributor

Re: Memory Utilization check using ps

One very import note:

export UNIX95=1 ; ps ...

is definitely NOT recommended. UNIX95, whenever it is defined (doesn't matter what value it has, just defined), will change the behavior of several commands and libraries. This is called XPG4 behavior, and when needed (like certain options in ps) is very useful. But defining it as an exported variable means that all subsequent commands and processes can inherit the variable and behave differently.

Instead, set UNIX95 as a temporary variable on the command line as in:

UNIX95= ps -eH

which causes ps to see UNIX95 as a defined value (in this case, null) and produce a hierarchical list of processes.


Bill Hassell, sysadmin
Conal O'Kelly
Advisor

Re: Memory Utilization check using ps

Thanks very much Bill.
I hadn't thought about the implication of setting the UNIX95 variable.

Cheers
Con