Domain Name Yahoo

Easy Help Troubleshoot Your Linux Box



  

Easy Help Troubleshoot Your Linux Box


Freeing Linux Virtual Memory

  

Hi,

I have Centos installed on HP Proliant Box with 13Gig of RAM Memory.
Yesterday, I was running rsync all my websites into another box in LAN.
Somehow the memory has dropped out and there is only 32Mb left on free memory.
Damn, only copying files has eating more than 12 Gigs of memory, and after rsync has finish and there is no more rsync process , the free mem won’t go back to normal. That is crazy !!.

I know you people will or even already have the same situation as I did.
Here is the tips. The secret is on /proc/sys/vm/drop_caches file.

Simply run this :

To free pagecache:
echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:
# echo 3 > /proc/sys/vm/drop_caches

Here is the example syntax and the result before and after freeing the memory.

[root@dev vm]# cd /proc/sys/vm/

[root@dev vm]# cat drop_caches
0
[root@dev vm]# free
total       used       free     shared    buffers     cached
Mem:       1132664    1085076      47588          0     194664     490084
-/+ buffers/cache:     400328     732336
Swap:      2031608          0    2031608
[root@dev vm]# sync ; echo 3 > /proc/sys/vm/drop_caches ; free
total       used       free     shared    buffers     cached
Mem:       1132664     388280     744384          0        116      48240
-/+ buffers/cache:     339924     792740
Swap:      2031608          0    2031608
You have new mail in /var/spool/mail/root
[root@dev vm]# cat drop_caches
3
[root@dev vm]# sync ; echo 0 > /proc/sys/vm/drop_caches ; free
total       used       free     shared    buffers     cached
Mem:       1132664     395952     736712          0       1336      55180
-/+ buffers/cache:     339436     793228
Swap:      2031608          0    2031608
note: don’t forget to put ‘0′ back into the drop_caches.

I still dont know if there will the any risk, until now.. everything is fine.


August 3rd, 2009 Posted by admin | CentOS, General, Ubuntu | no comments

No Comments »

No comments yet.

Leave a comment