Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've already run free -t -m and ps aux --sort -rss, but I don't understand why there's a difference between the output of these two commands regarding the amount of total physical memory currently being used. The outputs are as follows.

# free -t -m

             total       used       free     shared    buffers     cached
Mem:           995        863        132          0         30        658
-/+ buffers/cache:        173        821
Swap:            0          0          0
Total:         995        863        132

# ps aux --sort -rss

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
mysql      824  0.0  6.1 887776 63128 ?        Ssl  Feb24   0:35 /usr/sbin/mysqld
www-data  1411  0.0  1.5 235640 15696 ?        S    Feb24   0:01 /usr/sbin/apache2 -k start
www-data  1349  0.0  1.5 238744 15300 ?        S    Feb24   0:01 /usr/sbin/apache2 -k start
www-data  1158  0.0  1.4 238308 14812 ?        S    Feb24   0:02 /usr/sbin/apache2 -k start
www-data  1412  0.0  1.4 238264 14764 ?        S    Feb24   0:01 /usr/sbin/apache2 -k start
www-data   906  0.0  1.3 234120 14200 ?        S    Feb24   0:02 /usr/sbin/apache2 -k start
www-data  2673  0.0  1.3 234096 14044 ?        S    12:52   0:00 /usr/sbin/apache2 -k start
www-data  1413  0.0  1.2 236368 12916 ?        S    Feb24   0:01 /usr/sbin/apache2 -k start
www-data  2577  0.0  1.1 232496 12184 ?        S    10:54   0:00 /usr/sbin/apache2 -k start
www-data  1484  0.0  1.1 232180 12028 ?        S    Feb24   0:01 /usr/sbin/apache2 -k start
www-data  2675  0.0  1.1 231924 11704 ?        S    12:53   0:00 /usr/sbin/apache2 -k start
root       867  0.0  0.9 229388  9888 ?        Ss   Feb24   0:03 /usr/sbin/apache2 -k start
root      2939  0.0  0.4  88304  4084 ?        Ss   16:20   0:00 sshd: root@pts/0    
root      1023  0.0  0.3 584428  3840 ?        Sl   Feb24   0:00 /usr/sbin/console-kit-daemon --no-daemon
root      2956  0.0  0.3  21872  3148 pts/0    Ss   16:20   0:00 -bash
root       620  0.0  0.2  52252  2836 ?        Ss   Feb24   0:00 /usr/sbin/sshd -D
root         1  0.0  0.2  26756  2428 ?        Ss   Feb24   0:00 /sbin/init
syslog     428  0.0  0.1 247456  1560 ?        Sl   Feb24   0:01 rsyslogd -c5
root      3094  0.0  0.1  18600  1300 pts/0    R+   17:06   0:00 ps aux --sort -rss
root       316  0.0  0.1  21552  1272 ?        Ss   Feb24   0:00 /sbin/udevd --daemon
102        408  0.0  0.1  24004  1140 ?        Ss   Feb24   0:00 dbus-daemon --system --fork
root       766  0.0  0.1  21324  1028 ?        Ss   Feb24   0:00 cron
root       725  0.0  0.0  15828   976 tty5     Ss+  Feb24   0:00 /sbin/getty -8 38400 tty5
root       739  0.0  0.0  15828   976 tty3     Ss+  Feb24   0:00 /sbin/getty -8 38400 tty3
root       743  0.0  0.0  15828   976 tty6     Ss+  Feb24   0:00 /sbin/getty -8 38400 tty6
root       719  0.0  0.0  15828   972 tty4     Ss+  Feb24   0:00 /sbin/getty -8 38400 tty4
root       735  0.0  0.0  15828   964 tty2     Ss+  Feb24   0:00 /sbin/getty -8 38400 tty2
root       900  0.0  0.0  15828   960 tty1     Ss+  Feb24   0:00 /sbin/getty -8 38400 tty1
root       453  0.0  0.0  21548   816 ?        S    Feb24   0:00 /sbin/udevd --daemon
root       454  0.0  0.0  21548   816 ?        S    Feb24   0:00 /sbin/udevd --daemon
root       763  0.0  0.0   4376   684 ?        Ss   Feb24   0:00 acpid -c /etc/acpi/events -s /var/run/acpid.socket
root       313  0.0  0.0  17316   636 ?        S    Feb24   0:00 upstart-udev-bridge --daemon
root       303  0.0  0.0  15268   412 ?        S    Feb24   0:00 upstart-file-bridge --daemon
root       600  0.0  0.0  15256   412 ?        S    Feb24   0:00 upstart-socket-bridge --daemon
daemon     767  0.0  0.0  19124   168 ?        Ss   Feb24   0:00 atd
root         2  0.0  0.0      0     0 ?        S    Feb24   0:00 [kthreadd]

I've got 243068 KB (237 MB) as the sum of RSS column and the free command shows 863 MB being used. Am I doing something wrong? Can I assume the MySQL as the main process consuming the physical memory, despite the big difference? Is it really using 63128 KB (61 MB)?

**UPDATE**

Very nice website explaining how to interpret the free -t -m output: http://www.linuxatemyram.com/

share|improve this question
2  
Well... if you subtract "cached" from "used" in the output from free you get pretty close right? I think the source of the confusion here is Linux tendency to "reserve" RAM without using it. –  bigbadonk420 Feb 25 at 17:43
    
Yes, I would like someone explain me that difference or at least give me the reference to read more about. I feel really confused with these concepts. –  Orig Feb 25 at 17:53

1 Answer 1

up vote 0 down vote accepted

Here is a code to list processes and there memory usage from smaller to greater usage size .

sudo ps -e -orss=,args= | sort -b -k1,1n 

enter image description here

( you can add ,pid= if you want the process id )

You can learn about ps command Here

If you want graphically :

In dash , type System Monitor .

press Processes Tab

You can see each process by its memory usage under Memory

Press on Memory to sort them by Increasing order or decreasing

enter image description here

share|improve this answer
    
Thanks! I found this website (linuxatemyram.com) and it helped me a lot to understand what cache memory does. –  Orig Feb 25 at 20:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.