Troubleshoot Memory usage
Troubleshooting memory usage
A better checklist can be found at http://rimuhosting.com/howto/memory.jsp
Running "top" always tells you all RAM is used ? This is an example on the HG. Am I really using 124M of RAM ???
LinkStation:/media# top top - 11:41:03 up 2:40, 1 user, load average: 0.08, 0.14, 0.15 Tasks: 55 total, 2 running, 53 sleeping, 0 stopped, 0 zombie Cpu(s): 4.3% us, 3.3% sy, 0.0% ni, 89.8% id, 1.6% wa, 0.3% hi, 0.7% si Mem: 126496k total, 124636k used, 1860k free, 2928k buffers Swap: 522104k total, 25664k used, 496440k free, 61328k cached
It doesn't tell you the right story, as you'll see below.
/var/log/messages
Look for any "Out of memory" logs. You should not have any.
free -m
Any_Linux_box# free -m total used free shared buffers cached Mem: 90 85 4 0 3 34 -/+ buffers/cache: 46 43 Swap: 9 0 9
The top row 'used' (85) value will almost always nearly match the top row mem value (90). Since Linux likes to use any spare memory to cache disk blocks (34).The key figure to look at is the buffers/cache row used value (46). This is how much space your applications are currently using. For best performance, this number should be less than your total (90) memory. To prevent out of memory errors, it needs to be less than the total memory (90) and swap space (9).
ps aux
LinkStation:/media# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.4 2408 580 ? S 09:00 0:01 init [2] root 2 0.0 0.0 0 0 ? SN 09:00 0:00 [ksoftirqd/0] root 3 0.0 0.0 0 0 ? S< 09:00 0:00 [events/0] root 4 0.0 0.0 0 0 ? S< 09:00 0:00 [khelper] root 5 0.0 0.0 0 0 ? S< 09:00 0:00 [kthread] root 20 0.0 0.0 0 0 ? S< 09:00 0:00 [kblockd/0] root 23 0.0 0.0 0 0 ? S< 09:00 0:00 [khubd] root 56 0.0 0.0 0 0 ? S 09:00 0:00 [pdflush] root 57 0.0 0.0 0 0 ? S 09:00 0:00 [pdflush] root 59 0.0 0.0 0 0 ? S< 09:00 0:00 [aio/0] root 58 0.0 0.0 0 0 ? S 09:00 0:01 [kswapd0] root 643 0.0 0.0 0 0 ? S< 09:00 0:00 [kseriod] root 679 0.0 0.0 0 0 ? S 09:00 0:00 [mtdblockd] root 728 0.0 0.0 0 0 ? S 09:00 0:00 [kjournald] root 959 0.0 0.0 0 0 ? S 09:00 0:02 [kjournald] root 1341 0.5 0.1 1812 140 ? Ss 09:00 0:56 /sbin/dhcpcd-bi root 1497 0.0 0.4 1908 600 ? Ss 09:00 0:00 /sbin/syslogd - root 1503 0.0 0.2 1796 316 ? Ss 09:00 0:00 /sbin/klogd root 1509 0.0 0.3 1776 460 ? Ss 09:00 0:00 /usr/sbin/ppc_u root 1532 0.0 0.1 2184 128 ? S 09:00 0:00 /usr/sbin/ap_se root 1546 0.0 0.9 3464 1152 ? S 09:00 0:00 /bin/sh /usr/bi mysql 1607 0.0 8.6 130476 11000 ? Sl 09:00 0:09 /usr/sbin/mysql root 1608 0.0 0.4 1776 508 ? S 09:00 0:00 logger -p daemo root 1686 0.0 0.4 2384 520 ? Ss 09:00 0:00 /usr/sbin/dropb root 1707 0.0 2.2 7632 2848 ? S 09:00 0:03 ddclient - slee 102 1719 0.0 0.4 7088 532 ? Ss 09:01 0:00 /usr/sbin/exim4 root 1725 0.0 0.2 1784 320 ? Ss 09:01 0:00 /usr/sbin/inetd www-data 1731 0.0 1.0 5956 1328 ? S 09:01 0:00 /usr/sbin/light www-data 1736 0.0 3.7 17968 4796 ? Ss 09:01 0:00 /usr/bin/php5-c mldonkey 1742 9.6 28.9 48704 36672 ? Sl 09:01 15:49 /home/mldonkey/ www-data 1760 0.0 1.5 17968 1916 ? S 09:01 0:00 /usr/bin/php5-c www-data 1761 0.0 1.5 17968 1916 ? S 09:01 0:00 /usr/bin/php5-c www-data 1762 0.0 1.5 17968 1916 ? S 09:01 0:00 /usr/bin/php5-c www-data 1763 0.0 1.5 17968 1912 ? S 09:01 0:00 /usr/bin/php5-c nut 1764 0.0 0.4 2440 568 ? Ss 09:01 0:02 /lib/nut/newhid nut 1766 0.0 0.3 2292 432 ? Ss 09:01 0:00 /sbin/upsd root 1768 0.0 0.4 2284 568 ? Ss 09:01 0:00 /sbin/upsmon nut 1769 0.0 0.4 2284 580 ? S 09:01 0:00 /sbin/upsmon root 1772 0.0 0.7 7748 968 ? Ss 09:01 0:00 /usr/sbin/nmbd root 1774 0.0 0.5 11056 744 ? Ss 09:01 0:00 /usr/sbin/smbd root 1780 0.0 0.3 1776 504 ? Ss 09:01 0:00 /home/myscripts root 1783 0.0 0.3 1776 500 ? Ss 09:01 0:00 /home/myscripts root 1786 0.0 0.1 11056 220 ? S 09:01 0:00 /usr/sbin/smbd root 1797 0.1 1.0 10408 1368 ? S 09:01 0:10 Xvnc :1 -deskto root 1817 0.0 0.5 5148 676 ? S 09:01 0:00 vncconfig -icon root 1819 0.0 1.0 8360 1328 ? S 09:01 0:04 x-window-manage root 1856 0.0 3.2 4504 4092 ? SLs 09:01 0:00 /usr/sbin/ntpd daemon 1863 0.0 0.2 2452 340 ? Ss 09:01 0:00 /usr/sbin/atd root 1869 0.0 0.6 2992 780 ? Ss 09:01 0:00 /usr/sbin/cron root 1886 0.0 0.9 11016 1236 ? Ss 09:01 0:00 /usr/bin/perl / root 1915 0.0 0.9 11320 1204 ? S 09:44 0:00 /usr/sbin/smbd root 1917 0.4 2.2 11536 2800 ? S 09:50 0:30 /usr/sbin/smbd root 1974 0.0 0.8 2860 1024 ? Ss 09:56 0:02 /usr/sbin/dropb root 1975 0.0 1.4 3544 1812 pts/1 Ss 09:56 0:00 -bash root 2290 0.0 0.7 2784 992 pts/1 R+ 11:44 0:00 ps aux
The biggest RAM users here are mldonkey & mysql.
vmstat 1 2
LinkStation:/media# vmstat 1 2 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 3 0 25664 1980 2796 61316 1 3 126 37 186 355 14 4 78 4 0 0 25664 1924 2800 61348 0 0 4 0 155 354 3 2 94 1
The si (swap in) and so (swap out) columns show if you have been swapping (i.e. needing to dip into 'virtual' memory) in order to run your server's applications. The si/so numbers should be 0 (or close to it).