eppe
Posts: 19
Joined: Mon May 14, 2012 12:23 am

Memory usage

Sat May 26, 2012 8:22 am

Hi,

I am quite new on Linux and I am trying to understand the high memory usage I always get on my freshly installed Debian on the Raspberry pi.

Code: Select all

pi@raspberrypi:~$ ps -aux
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   2076   188 ?        Ss   03:02   0:01 init [2]  
root         2  0.0  0.0      0     0 ?        S    03:02   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    03:02   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S    03:02   0:01 [kworker/u:0]
root         6  0.1  0.0      0     0 ?        S    03:02   0:35 [rcu_kthread]
root         7  0.0  0.0      0     0 ?        S<   03:02   0:00 [khelper]
root         8  0.0  0.0      0     0 ?        S    03:02   0:00 [kdevtmpfs]
root         9  0.0  0.0      0     0 ?        S    03:02   0:00 [sync_supers]
root        10  0.0  0.0      0     0 ?        S    03:02   0:00 [bdi-default]
root        11  0.0  0.0      0     0 ?        S<   03:02   0:00 [kblockd]
root        12  0.0  0.0      0     0 ?        S    03:02   0:00 [khubd]
root        13  0.0  0.0      0     0 ?        S<   03:02   0:00 [rpciod]
root        14  0.0  0.0      0     0 ?        S    03:02   0:07 [kswapd0]
root        16  0.0  0.0      0     0 ?        S    03:02   0:00 [fsnotify_mark]
root        17  0.0  0.0      0     0 ?        S<   03:02   0:00 [nfsiod]
root        18  0.0  0.0      0     0 ?        S<   03:02   0:00 [crypto]
root        25  0.0  0.0      0     0 ?        S<   03:02   0:00 [VCHIQ-0]
root        26  0.0  0.0      0     0 ?        S<   03:02   0:00 [VCHIQr-0]
root        27  0.0  0.0      0     0 ?        S<   03:02   0:00 [dwc_otg]
root        28  0.0  0.0      0     0 ?        S<   03:02   0:00 [DWC Notificatio]
root        29  0.0  0.0      0     0 ?        S    03:02   0:00 [kworker/u:1]
root        30  3.9  0.0      0     0 ?        D    03:02  14:32 [mmcqd/0]
root        31  0.0  0.0      0     0 ?        S    03:02   0:03 [jbd2/mmcblk0p2-]
root        32  0.0  0.0      0     0 ?        S<   03:02   0:00 [ext4-dio-unwrit]
root        73  0.0  0.1   2480   392 ?        S<s  03:02   0:00 udevd --daemon
root       660  0.0  0.0   1712   160 ?        S    03:03   0:11 /usr/sbin/ifplugd -i eth0 -q -f -u0 -d10 -w -I
daemon     661  0.0  0.0   1828   120 ?        Ss   03:03   0:00 /sbin/portmap
statd      676  0.0  0.0   2040   132 ?        Ss   03:03   0:00 /sbin/rpc.statd
root       677  0.0  0.0   1712   164 ?        S    03:03   0:03 /usr/sbin/ifplugd -i lo -q -f -u0 -d10 -w -I
root       860  0.0  0.3  27544   828 ?        Sl   03:03   0:02 /usr/sbin/rsyslogd -c4
102        910  0.0  0.2   2836   552 ?        Ss   03:03   0:00 /usr/bin/dbus-daemon --system
root       928  0.0  0.1   3968   248 ?        Ss   03:03   0:00 /usr/sbin/cron
root       936  0.0  0.0   2308   100 ?        Ss   03:03   0:00 dhclient -v -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
116        947  0.0  0.5  15184  1316 ?        Ssl  03:03   0:00 /usr/sbin/hald
root       948  0.0  0.3   3720   676 ?        S    03:03   0:00 hald-runner
ntpd       959  0.0  0.3   5432   720 ?        Ss   03:03   0:04 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 119:127
root       997  0.0  0.1   5884   384 ?        Ss   03:03   0:00 /usr/sbin/sshd
root      1024  0.0  0.0   3736   148 tty1     Ss   03:03   0:00 /bin/login --   
root      1025  0.0  0.1   1704   232 ?        Ss+  03:03   0:00 /sbin/getty -L ttyAMA0 115200 vt100
root      1026  0.0  0.0   3736   148 tty3     Ss   03:03   0:00 /bin/login --     
root      1027  0.0  0.0   1704   120 tty4     Ss+  03:03   0:00 /sbin/getty 115200 tty4
root      1028  0.0  0.0   1704   120 tty5     Ss+  03:03   0:00 /sbin/getty 115200 tty5
root      1029  0.0  0.0   1704   120 tty6     Ss+  03:03   0:00 /sbin/getty 115200 tty6
root      1031  0.0  0.7  17612  1692 ?        Sl   03:03   0:00 /usr/sbin/console-kit-daemon --no-daemon
pi        1103  0.0  0.3   4708   848 tty1     S    03:03   0:01 -bash
root      1150  0.0  0.0      0     0 ?        D    03:56   0:10 [flush-179:0]
root      2780  0.0  0.2   2476   496 ?        S<   04:29   0:00 udevd --daemon
root      2782  0.0  0.2   2476   504 ?        S<   04:29   0:00 udevd --daemon
root      2797  0.0  0.5   3820  1120 ?        S    04:29   0:00 hald-addon-input: Listening on /dev/input/event0 /dev/input/event1
pi        3066  0.0  0.6   3956  1408 tty1     S+   04:35   0:00 make
root     17223  0.0  0.0      0     0 ?        S    07:44   0:03 [kworker/0:2]
root     22652  0.0  0.0      0     0 ?        S    09:07   0:00 [kworker/0:1]
pi       22938  0.0  0.4   3588   996 tty1     S+   09:09   0:00 make -f scripts/Makefile.build obj=sound
pi       23028  0.0  0.4   3588  1012 tty1     S+   09:10   0:00 make -f scripts/Makefile.build obj=sound/core
pi       23136  0.2  0.4   3588  1048 tty1     S+   09:11   0:00 make -f scripts/Makefile.build obj=sound/core/seq
root     23283  0.0  0.0      0     0 ?        S    09:13   0:00 [kworker/0:0]
pi       23343  0.2  0.4   3588  1024 tty1     S+   09:13   0:00 make -f scripts/Makefile.build obj=sound/core/seq/oss
root     23400  2.6  1.3   9480  2952 ?        Ss   09:14   0:00 sshd: pi [priv]  
pi       23427  0.4  0.6   9480  1512 ?        S    09:14   0:00 sshd: pi@pts/0   
pi       23428  0.4  0.8   4692  1792 pts/0    Ss   09:14   0:00 -bash
pi       23450  0.3  0.2   1728   512 tty1     S+   09:14   0:00 /bin/sh -c set -e; ?   echo '  CC [M]  sound/core/seq/oss/seq_oss_writeq.o'; gcc -Wp,-MD,sound/co
pi       23451  0.3  0.3   3336   764 tty1     S+   09:14   0:00 gcc -Wp,-MD,sound/core/seq/oss/.seq_oss_writeq.o.d -nostdinc -isystem /usr/lib/gcc/arm-linux-gnue
pi       23452  109  5.9  22252 13396 tty1     R+   09:14   0:03 /usr/lib/gcc/arm-linux-gnueabi/4.4.5/cc1 -quiet -nostdinc -I/home/pi/kernel/linux/arch/arm/includ
pi       23453  0.0  0.4   4068  1012 pts/0    R+   09:14   0:00 ps -aux
pi@raspberrypi:~$ free -m
             total       used       free     shared    buffers     cached
Mem:           218        200         18          0         18        148
-/+ buffers/cache:         33        185
Swap:          190          4        186
I can not see any correlation between the number shown by free -m (200MB used, 4MB of swap) and the ps -aux output.
ps does not shown any heavy process.

How can I find the processes using a large amount of memory ?

Thank you.

shirro
Posts: 248
Joined: Tue Jan 24, 2012 4:54 am

Re: Memory usage

Sat May 26, 2012 8:39 am

You have 33MB used and 185MB free. Of that 148+18MB are being used for cache and buffers to speed up your system and that can be used by programs as required.

BTW if you are using swap on an sd card you might want to check if your system is setting vm.swappiness nice and low with cat /proc/sys/vm/swappiness - swapping on sd card will slow your system down a lot as it is really slow and might reduce the cards lifetime.

If it isn't a really low number reported you can add vm.swappiness=X to your /etc/sysctl.conf where X is a smallish integer. I don't know what is optimal really. 5, 10?

If you want to see the top memory users try ps aux --sort -rss |head and look at the RSS size which is in kB

eppe
Posts: 19
Joined: Mon May 14, 2012 12:23 am

Re: Memory usage

Sat May 26, 2012 8:45 am

shirro wrote:You have 33MB used and 185MB free. Of that 148+18MB are being used for cache and buffers to speed up your system and that can be used by programs as required.
Thank you shirro for pointing that out.
I guess I will try to understand deeper those cache and buffers to get how it works.

eppe
Posts: 19
Joined: Mon May 14, 2012 12:23 am

Re: Memory usage

Sat May 26, 2012 8:55 am

shirro wrote: BTW if you are using swap on an sd card you might want to check if your system is setting vm.swappiness nice and low with cat /proc/sys/vm/swappiness - swapping on sd card will slow your system down a lot as it is really slow and might reduce the cards lifetime.

If it isn't a really low number reported you can add vm.swappiness=X to your /etc/sysctl.conf where X is a smallish integer. I don't know what is optimal really. 5, 10?
Thank you, it is good to know.
Actually I have enabled it after multiple failure trying to clone the git raspberry Linux kernel repository.
I think I will disabled it after that.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Memory usage

Sat May 26, 2012 9:24 am

This is something that always seems to confuse new Linux users ;)
http://www.google.co.uk/search?q=linux+ ... ree+output

Return to “Beginners”