amerikanjunkie
various one
Registered: Aug 2000
Location:
Posts: 1731 |
Process Memory Usage and Linux
Process Memory Usage and Linux
February 6th, 2006 by cvcrud
http://cvcrud.jedicoder.net
Some of you may have recently read an article on Slashdot detailing why TOP and PS present flase values. If you didnt, that is ok, because I am going to sum it up for you here, keeping in tune with the previous post about linux performance.
Alot of you may know that TOP and PS arent the greatest reporting tools for memory and cpu usage. But why are they not good reporting tools? Because when a program is ran, it accesses various parts of many shared libraries used by other programs. This library is only loaded ONCE into memory to be accessed by various processes. However, when you run TOP or PS, it adds the size of the shared library to the memory total for each process that accesses it. So if you have 6 processes, all accessing lib*.so.5, it will add the size of lib*.so.5 six times, even though it is only actually being loaded into memory once. That is reported to TOP and PS, thus giving you false results.
Lets take firefox for example, when I do a “ps aux | grep firefox-bin”, I get the following:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
73160 5876 2.5 4.8 133296 50616 ? Sl 08:36 2:04 /usr/lib/firefox/firefox-bin
It shows that Virtual memory being used is 133 Megs (Virtual Memory = Resident + SWAP), the Resident memory usage is 50 megs. Now lets do a: pmap -d 5876 —- the PID of firefox-bin…..
[root@blah ~]# pmap -d 5876 | grep mapped
mapped: 133316K writeable/private: 95916K shared: 1716K
The writeable/private gives you the “incremental cost” of running the process “factoring out the shared libraries”. Firefox-bin is actually accessing/using about 95 Megs, versus 133 Megs.
Report this post to a moderator |
IP: Logged
|