Linux Memory Question

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
from man proc:

vsize %lu
Virtual memory size in bytes.

rss %ld
Resident Set Size: number of pages the process has in
real memory, minus 3 for administrative purposes. This is
just the pages which count towards text, data, or stack
space. This does not include pages which have not been
demand-loaded in, or which are swapped out.

I am trying to gather per process physical memory used and virtual memory used by parsing /proc/(PID)/stat.

I assumed that VM was amount in virtual memory, and RSS was size in real memory. The problem came when I realized I dont' know what RSS is in, bytes, K, G?

is VM really RSS - VM from the stat file?
 

TGS

Golden Member
May 3, 2005
1,849
0
0
Can you use ps with s (for memory size in KB) and vsize (for total VM size in bytes)?
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
I have a script running that parses the stat file for each PID. We needed CPU time down to the 1/100th of a second (or a Jiffie). I have to output the script in a very strict format for a prewritten tool to read it correctly (i.e. the windows guy found prebuilt tools, pslist and pslist -t and had the tool written to read it's format). I would have to start over on a new script to do this....
 

TGS

Golden Member
May 3, 2005
1,849
0
0
Whats the format that you need it in.

CSV to a file, or just a appended output, etc...

What does the output structure look like?
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
C:\Documents and Settings\nickw>pslist -t

PsList 1.26 - Process Information Lister
Copyright (C) 1999-2004 Mark Russinovich
Sysinternals - www.sysinternals.com

Process information for KEYLABSLT2:

Name Pid Pri Thd Hnd VM WS Priv
Idle 0 0 1 0 0 16 0
System 4 8 56 280 1840 220 0
smss 1172 11 3 21 3760 464 172
csrss 1376 13 11 366 24496 3872 1672
winlogon 1400 13 19 586 53100 5368 7508
services 1444 9 16 270 19924 3008 1404
svchost 184 8 14 166 28988 4200 1436
spoolsv 524 8 13 179 30500 4984 3088
svchost 1624 8 9 241 19824 3468 1184
WINWORD 600 8 5 300 123488 2100 13336
svchost 1668 8 73 1433 117536 20136 13344
svchost 1772 8 6 72 12580 1960 712
wdfmgr 1816 8 4 58 12276 1560 420
lsass 1456 9 20 330 36052 664 3264
explorer 1196 8 15 490 102260 27924 18804
OUTLOOK 400 8 21 876 228652 18612 16276
firefox 432 8 13 249 76024 19548 15520
EXCEL 864 8 3 185 76248 12700 5520
cmd 1068 8 1 20 13216 1368 1416
pslist 560 13 2 90 17324 1740 744
ctfmon 1316 8 1 139 19356 2888 504
YPager 1328 8 12 335 110928 25940 15400

C:\Documents and Settings\nickw>



not sure how well that will retain formatting...that is the output from the windows command.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Remember VM does not equal swap space, the virtual size is the amount of virtual addresses in use by the process. This would include normal RSS size plus any other mappings for mmaped files, mapped libraries, etc. Where the data lies (in memory, on disk, in swap, etc) is irrelevant to the virtual size.

From looking at the proc man page I don't think you can get the amount of swapped out pages from /proc/pid/stat, if that's what you're really looking for.
 

TGS

Golden Member
May 3, 2005
1,849
0
0
Pid(process ID) Pri(priority) Thd(threads) Hnd(handles) VM(virtual memory) WS Priv , Last two?

Is that the correct information that it's pulling?

Edit:

I'm looking at ps u -e|more, looks almost albeit not the column format as your pslist output. You could always pipe to awk and pipe out the format you want to see. Though I may be trying to reinvent the wheel on your scripts.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
Priv(ate virtual memory usage) and WS(working set. Trying to find what they say these are on the systernals site.