Hi every1, I have a quick question do you have any thoughts on how to get a reasonable value for memory usage of a process in linux? I am currently using ps however it is reporting 3 namely rss ,vsz and size and I dont know how to use these. I have read some articles on internet and all of them are rather discouraging i.e. they all tell that it is really hard to determine a reasonable value for size of memory a process is using, some state that rss+vsz might be a good measure, but I might have misunderstood.. im open to even the quickest ideas, thanx in adv.
Oz.
linux process memory usage
Re:linux process memory usage
Short(not perfectly correct) answer is:
rss = how much memory is currently being used
vsz = how much memory the program thinks it's taking up
size = vsz + memory the program is using for files
The difference between rss and vsz is because the OS pages out chunks of applications that haven't been used in a while(usually to swap). As long as you system isn't short on memory already rss should give you a close enough estimate on memory average memory usage for a program.
None of this takes in to account shared memory where two or more programs can overlap each other. ps isn't smart enough to notice the overlap, sometime you can add up all the memory used that ps shows and it'll be more memory then you have.
In truth the amount of memory a new run of a process takes up varies based on what other process you have running on your system. The only real way to determine memory usage is with pmap but that is not easy to use. Several people have written scripts that parse pmap to give more accurate numbers. Several programs use more shared memory than others, like databases.
rss = how much memory is currently being used
vsz = how much memory the program thinks it's taking up
size = vsz + memory the program is using for files
The difference between rss and vsz is because the OS pages out chunks of applications that haven't been used in a while(usually to swap). As long as you system isn't short on memory already rss should give you a close enough estimate on memory average memory usage for a program.
None of this takes in to account shared memory where two or more programs can overlap each other. ps isn't smart enough to notice the overlap, sometime you can add up all the memory used that ps shows and it'll be more memory then you have.
In truth the amount of memory a new run of a process takes up varies based on what other process you have running on your system. The only real way to determine memory usage is with pmap but that is not easy to use. Several people have written scripts that parse pmap to give more accurate numbers. Several programs use more shared memory than others, like databases.
Re:linux process memory usage
thanks for reply and explanation chase,
it seems to me (based on pure observation) that size should be a reasonable estimate of used memory because it is nearly the same when I observe it on different machines, vsz and rss usually are differing by significant amount (most probably based on current state of os, i guess) let me check pmap otw i think ill go with size.. thanx again.
Oz.
it seems to me (based on pure observation) that size should be a reasonable estimate of used memory because it is nearly the same when I observe it on different machines, vsz and rss usually are differing by significant amount (most probably based on current state of os, i guess) let me check pmap otw i think ill go with size.. thanx again.
Oz.
Re:linux process memory usage
"man ps" (on Solaris 8) gives me::
rss - The resident set size of the process, in kilobytes. The rss value reported by ps is an estimate provided by proc(4) that may underestimate the actual resident set size. Users who wish to get more accurate usage information for capacity planning should use pmap(1) -x instead.
vsz - The total size of the process in virtual memory, in kilobytes.
SZ - The total size of the process in virtual memory, including all mapped files and devices, in pages. See pagesize(1).
rss - The resident set size of the process, in kilobytes. The rss value reported by ps is an estimate provided by proc(4) that may underestimate the actual resident set size. Users who wish to get more accurate usage information for capacity planning should use pmap(1) -x instead.
vsz - The total size of the process in virtual memory, in kilobytes.
SZ - The total size of the process in virtual memory, including all mapped files and devices, in pages. See pagesize(1).
Every good solution is obvious once you've found it.
Re:linux process memory usage
great, then ill absolutely go with size, pmap seems rather complicated anyway.. thanks..