cancel
Showing results for 
Search instead for 
Did you mean: 

Memory usage of a process

porwaa
Advisor

Memory usage of a process

I want to know programitically the memory usage of a process running on HP-PA RISC unix system. Is there a system call to do so?
I know there is a strcut pst_vminfo structure . can we use the same?
4 REPLIES
Don Morris_1
Honored Contributor

Re: Memory usage of a process

You mean struct pst_vminfo -- and no, for what you're asking that isn't the right one. pst_vminfo describes system-wide VM information. Per process would be a summation of the struct pst_vm_status structures returned by looping through pstat_getprocvm() until you get a zero or negative return. man 2 pstat has more information.
porwaa
Advisor

Re: Memory usage of a process

I have used pstat_getprocvm for finding the memory usage without luck. Note that I wish to get the details for only one process.
The below parameters should give respectivily the virtual and physical memory usage.
pvs.pst_length, pvs.pst_phys_pages


I use the below call
pstat_getprocvm(&pvs, sizeof(struct pst_vm_status), pid, i)
but does not provide the output. Should it be used in a loop
Steven E. Protter
Exalted Contributor

Re: Memory usage of a process

Shalom,

http://www.hpux.ws/?p=8

That link may be of interest. It works on PA-RISC and Itanium systems.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Don Morris_1
Honored Contributor

Re: Memory usage of a process

Yes, that's why I said "returned by looping through pstat_getprocvm()" until you get a terminating return value (negative or 0).

From the man page "There is one instance of this context for each process region contained in the process's address space." Hence if you want the summation of all regions.. you have to iterate through the contexts.

Sample code attached.