Free memory by flushing pagecache and slabcache

เราสามารถทำการ free memory ได้แบบ on demand โดยใช้คำสั่งง่ายๆ ซึ่งวิธีการนี้จะเป็นการ clear memory ในส่วนของ pagecache และ slabcache ในระบบ linux

วิธีการก็คือ ใส่ค่า 1 สำหรับ free pagecache, 2 สำหรับ free dentries และ inodes หรือ 3 สำหรับ free pagecache, dentries และ inodes เข้าไปยังไฟล์ /proc/sys/vm/drop_caches นั้นเอง

ตัวอย่างการ free momory หรือ clear momery

คำสั่งสำหรับ free pagecache:
# echo 1 > /proc/sys/vm/drop_caches

คำสั่งสำหรับ free dentries และ inodes:
# echo 2 > /proc/sys/vm/drop_caches

คำสั่งสำหรับ free pagecache, dentries และ inodes:
# echo 3 > /proc/sys/vm/drop_caches

คำแนะนำ: ถ้าทำการ free memory ในขณะที่ server กำลังใช้งาน memory และ I/O อย่างหนักอาจจะทำให้เกิด deadlock ได้

Related posts:

  1. วิธีอ่าน Memory Usage ด้วย free command การใช้งาน ram แบบไม่เกรงใจใครนั้นเป็นเรื่องปกติสำหรับ linux เพราะว่า kernel จะมีการใช้งาน ram...
  2. Rescan SCSI to add, remove SCSI device without rebooting To rescan an entire SCSI bus and re-register...
  3. Enable Core Dumps for Daemons or Services in Red Hat Enterprise Linux โดยทั่วไปแล้ว daemon เป็นการทำงานในรูปแบบ background process การสั่งให้ deamond ทำงานสามารถทำได้โดยใช้...
  4. Setup MRTG to monitor CPU workload , Memory and Disk use status with IOSTAT. การติดตั้ง mrtg ในการ monitor สถานะต่างๆ ที่จะพูดถึงต่อไปนี้เป็นการนำ monitor tools...
  5. Controlling Core Dump Files in Linux Core dump อีกแล้ว!! คำพูดนี้เกิดขึ้นหลังจากที่เพื่อนคนหนึ่งได้โทรมาถามปัญหาเรื่องการใช้ rpm เสร็จ ตอนแรกก็งงๆ core...

You can leave a response, or trackback from your own site.

Leave a Reply