1754976 Members
3339 Online
108828 Solutions
New Discussion юеВ

Re: Process Memory size

 
SOLVED
Go to solution
Satish Kumar Malisetti
Frequent Advisor

Process Memory size

Hello

I want to know a memory size of a process in hp ux

Regards,
Sathish
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: Process Memory size

Hi:

In a shell, use 'ps'. If you are writing in C, you have the underlying 'pstat()' interface.

Regards!

...JRF...
Satish Kumar Malisetti
Frequent Advisor

Re: Process Memory size

In shell i can see only by ps

UID PID PPID C STIME TTY TIME COMMAND

not the memory size
Satish Kumar Malisetti
Frequent Advisor

Re: Process Memory size

James,,


Please let me know how to verify memory occupied by a particluar process
James R. Ferguson
Acclaimed Contributor
Solution

Re: Process Memory size

Hi (again) Sathish:

In the shell, you can do:

# UNIX95= ps -C myprocess -opid,vsz

This leverages the UNIX95 (XPG) behavior of 'ps' and allows you to create a custom list of the fields that 'ps' can report. In this case, we look for a process named "myprocess" and report its pid and virtual segment size.

Note the whitespace following the "=". There is no semicolon before the 'ps' and this keeps the UNIX95 behavior only for the duration of the command line. Setting UNIX95 in your environment may have effects on other commands that you will not necessarily be aware of.

Regards!

...JRF...
Satish Kumar Malisetti
Frequent Advisor

Re: Process Memory size

JRF

Please look into the below example i am not getting result as expected

cbh10702 $ ps
PID TTY TIME COMMAND
4843 pts/tF 0:00 nameserv
4910 pts/tF 0:29 cor
4343 pts/tF 0:00 telnetd
9481 pts/tF 0:00 ps
4855 pts/tF 0:23 java
4344 pts/tF 0:00 ksh
cbh10702 $ UNIX95= ps -C 4910 -opid,vsz
PID VSZ



Please let me know how to do it

Dennis Handly
Acclaimed Contributor

Re: Process Memory size

>look into the below example I am not getting result as expected

You need to use:
UNIX95=EXTENDED_PS ps -p 4910 -opid,vsz

(-p is for PID, -C is for executable name)
James R. Ferguson
Acclaimed Contributor

Re: Process Memory size

Hi (again):

As you now know, you must do:

# UNIX95= ps -p 4910 -opid,vsz

...if you want to specify the *pid* of the process and substitute '-C for '-p ' to search by the a command's basename.

Dennis prefers to use:

# UNIX95=EXTENDED_PS

...to signify the we want the enhanced UNIX95 (XPG4) behavior. I prefer the shorter form:

# UNIX95=

Both are equavalent to:

# UNIX95=1
# UNIX95=0

Take note that the declaration and assignment of UNIX95 is sufficient to enable the behavior. You could just as easily set the variable to zero as you could to one.

This is why I prefer the short form:

# UNIX95= ps ...

To me, the short form is a reminder that that you can't reset the behavior by assigning zero (or anything).

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Process Memory size

>JRF: Dennis prefers to use: UNIX95=EXTENDED_PS

(Actually I show it that way so I don't have provide a thesis to explain it. And can search for those solutions. :-)