VmSize in /proc/<pid>/status
Hi All,
Linux: ------- To get 'VmSize' in Linux, i was trying to read file /proc/<pid>/status and search for 'VmSize' to identify the VmSize of the process. How to get VmSize in Solaris 5.10 platform? I opened /proc/$$/status but it looks like this file is non-readable (not in ascii format). How to get VmSize from path /proc/<pid>/... in Solari platform? Thanks |
The "/proc" files on Solaris are not text file so you just can "cat" them and pull out the fields you want. It's been a very, very long time since I wrote Solaris code that read "/proc" data but it's pretty straightforward as long as you're programming in C.
You just have to read the man pages to figure out what structure goes with the "/proc" file (or files) that have the data you're interested in. But in the end, once you have the structure identified getting data from "/proc" files is simpler on Solaris than Linux, since it's parse into fields automatically. |
Thanks.
in Linux: /proc/PID/status - the field name is 'VmSize' in Solaris: I found there is pstatus_t structure, in the below structure which field indicates the virtual memory size (in other words, equal field name of Linux VmSize value). Code:
typedef struct pstatus { |
This small C code will read the virtual size of a process when getting its input from /proc/<pid>/psinfo file (not the /proc/<pid>/status one):
Code:
#include <stdio.h> |
Thanks.
Do we need divide using getpagesize() function returned value? can you please confirm. Code:
ps -opid,ppid,vsz -u <userid> | grep 14390 -------- 14390 13286 1568 vm size seems to be 1568. Code:
#include <stdio.h> ---------- pr_size: 1568 vm size: 196 |
You can simplify your test command with:
Code:
ps -opid,ppid,vsz -p 14390 Code:
size_t pr_size; /* size of process image in Kbytes */ |
Thank you Jlliagre, cnamejj and appreciated for your inputs.
|
You are welcome.
Again, please edit your previous postings to include code tags. |
I have added code tags, thanks for letting me the steps to add the code tags.
|
All times are GMT -5. The time now is 08:48 PM. |