Err.. memory going crazy
> dfischer@li93-201:~$ free -m
total used free shared buffers cached
Mem: 540 534 6 0 6 231
-/+ buffers/cache: 296 243
Swap: 255 0 255
dfischer@li93-201:~$ free -m
total used free shared buffers cached
Mem: 540 479 60 0 6 233
-/+ buffers/cache: 240 300
Swap: 255 0 255
dfischer@li93-201:~$ free -m
total used free shared buffers cached
Mem: 540 466 73 0 6 233
-/+ buffers/cache: 226 313
Swap: 255 0 255
dfischer@li93-201:~$ free -m
total used free shared buffers cached
Mem: 540 452 87 0 6 233
-/+ buffers/cache: 213 327
Swap: 255 0 255
dfischer@li93-201:~$ free -m
total used free shared buffers cached
Mem: 540 457 82 0 6 233
-/+ buffers/cache: 217 322
Swap: 255 0 255
dfischer@li93-201:~$
dfischer@li93-201:~$ free -m
total used free shared buffers cached
Mem: 540 433 106 0 6 233
-/+ buffers/cache: 193 346
Swap: 255 0 255
dfischer@li93-201:~$ free -m
total used free shared buffers cached
Mem: 540 432 108 0 6 233
-/+ buffers/cache: 192 347
Swap: 255 0 255
dfischer@li93-201:~$ free -m
That was all in the span of 10 seconds.
When I top top + shift + m
the thing at the top is mysql (8% memory) and then apache instances about 10 of them at 2-4% totaling up to about 20-30%
should I try to tweak mysql settings? it's at the default right now.
6 Replies
> free -m
total used free shared buffers cached
Mem: 540 464 75 0 41 276
-/+ buffers/cache: 146 393
Swap: 383 20 363
> top
top - 11:42:33 up 5 days, 2:58, 1 user, load average: 0.14, 0.16, 0.12
Tasks: 89 total, 2 running, 87 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.8%us, 0.3%sy, 0.0%ni, 98.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 553184k total, 476328k used, 76856k free, 43168k buffers
Swap: 393208k total, 52k used, 393156k free, 283088k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2330 mysql 15 0 77808 53m 4928 S 0 9.9 38:14.19 mysqld
22016 www-data 15 0 165m 42m 24m S 0 7.9 0:00.98 apache2
22015 www-data 15 0 156m 26m 18m S 3 4.8 0:00.70 apache2
22032 www-data 15 0 156m 25m 16m S 0 4.7 0:00.74 apache2
22031 www-data 15 0 155m 24m 17m S 0 4.6 0:00.84 apache2
22030 www-data 15 0 153m 10m 5988 S 0 2.0 0:00.17 apache2
22027 www-data 15 0 152m 9996 5164 S 0 1.8 0:00.06 apache2
22041 www-data 20 0 152m 9536 5176 S 0 1.7 0:00.03 apache2
22040 www-data 15 0 152m 9524 5132 S 0 1.7 0:00.04 apache2
2514 root 18 0 151m 8056 4812 S 0 1.5 0:10.67 apache2
2599 root 15 0 6816 4956 1544 S 0 0.9 0:00.96 munin-node
2713 root 18 0 23288 4000 1592 S 0 0.7 0:01.03 fail2ban-server
and then after reloading apache
> free -m
total used free shared buffers cached
Mem: 540 473 66 0 42 276
-/+ buffers/cache: 154 385
Swap: 383 0 383
@Moses:
On this topic, I can't figure out why I'd be using swap when there's plenty of free memory?
> free -mtotal used free shared buffers cached
Mem: 540 464 75 0 41 276
-/+ buffers/cache: 146 393
Swap: 383 20 363
You're using 20Mb of swap. This is a feature of the Linux kernel to throw things out that really aren't in use. Even when you have free memory Linux can swap stuff out that really isn't in use.
My real machine at home has 4Gb RAM, currently has 182Mb in use and has swapped 200Kb. My linode 360 has 40Mb in use, but has 5Mb swapped. My Panix v-colo 360 has 43Mb in use and 4Mb swap.
It's just how Linux tries to optimise memory usage. That 20Mb of swap space used means 20Mb of extra RAM for real usage.
sysctl -w vm.swappiness=
echo "vm.swappiness=
The lower the number the less chance of swapping, 0 switches it off. I have it set at 30, I think the default is 50.