Portal Home > Knowledgebase > Articles Database > Swap memory issue


Swap memory issue




Posted by bonjurkes, 03-26-2010, 01:57 PM
Hey, I am using a server with 4 gigs of ram and with 1 gig of swap memory. But recently swap memory gets fulled pretty fast. For example, i cleaned my swap memory this morning, 10 hours past and its %100 again. Is there a way to find what is causing swap memory get %100 ? Normally, swap memory should decrease when it's not in use but it just stays at %100 till i give swapoff and swapon command.

Posted by Hostify Networks, 03-26-2010, 08:50 PM
You are referring to the swap space on the hard disk correct? If so, I would think that 1GB would be less than what is generally recommended. Most of the time, when swap is being used, this means that all of the available RAM is being utilized. This could be caused by either a runaway process/memory leak or by not having enough memory for what you're running. What is the output of this?I'm guessing that it will show all of your memory is being utilized. If so, run top and see if you can spot the process that is hogging it all.

Posted by ServerManagement, 03-26-2010, 09:16 PM
The swap is usually 2x the memory, or at least 1x the memory. If you have 4gig of ram, then 1gig swap is too little. You will need to check the activity of the server while the swap is high to see what is happening. Look at "top" and monitor the activity.

Posted by VIPoint, 03-27-2010, 08:28 AM
The swap is usually 2X the memory but that was when servers used 512 MB RAM. 1 GB of SWAP memory is good enough. If the SWAP memory is getting filled this fast then there is some problem with your server. Check the processes that are using up the swap memory.

Posted by Crashus, 03-27-2010, 08:42 AM
Yes 1G of fwap with 4G of RAM is enough. Looks like you have memory leak, reboot the box and look at top output, most-likely it will help you.

Posted by bonjurkes, 03-27-2010, 09:11 AM
Ok, i turned back swap on (which i forgot to do from last time). I will wait some time to get it filled up. And i don't have clue about what is causing that, because for example memory usage is %20 but swap memory is %100, and it never drops back from %100. I will try to check top, and put output of free -m command here soon

Posted by bonjurkes, 04-08-2010, 12:44 PM
swap is %100 again free -m output is : total used free shared buffers cached Mem: 3934 3723 211 0 168 2302 -/+ buffers/cache: 1252 2682 Swap: 1027 1027 0 why cached is 2302, is it too much ?

Posted by marrtins, 04-08-2010, 03:42 PM
Cached means Linux has used 2302mb for disk cache. Actually it's usable memory - you can count it as free memory for sure though. It's a very strange swap usage. Perhaps some processes use all memory and swap and then respawn? It's very common for apache. Check /var/log/messages or /var/log/syslog for "oom-killer". What is output of `cat /proc/sys/vm/swappiness`?

Posted by bonjurkes, 04-08-2010, 04:17 PM
cat /proc/sys/vm/swappiness output is 60 and nothing for oom-killer

Posted by marrtins, 04-08-2010, 04:51 PM
60 is default, so nothing suspicious. Can you spot most memory hungry process? Try `top` and then sort by memory usage (Shift+M)

Posted by bonjurkes, 04-08-2010, 04:53 PM
It's mysql, all the time, and rarely apache for few connections, then it goes back normal but mysql is mostly like %8 memory usage. When i checked today, it was %8 memory and %16 cpu, but when i check mysql process, there was only 1 query in sleep mode, thats all

Posted by marrtins, 04-08-2010, 05:03 PM
Then maybe this is just a burst/peak memory usage scenario and no worries should be made if you got 2GB+ cached (free) memory now? Try to monitor swap partition usage. You can do this with iostat or sar utilities (I believe you must install them first, if not installed already).

Posted by bonjurkes, 04-08-2010, 05:08 PM
actually, it all goes normal for sometime, i don't check for sometime, and when i check, swap is already full. But it doesn't cause any extra load etc. Just wondering what is really causing that swap thing. I have APC on the server, but i don't think it may affect on that.

Posted by Sileep Kumar M S, 04-10-2010, 07:01 AM
What is the kernel version?

Posted by bonjurkes, 04-10-2010, 07:23 AM
kernel is : 2.6.18-164.15.1.el5



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
interserver.net downed (Views: 670)
Afoordablehost? (Views: 841)

Language: