Practical skills: release cache memory in Linux

Source: Internet
Author: User
/Proc is a virtual document system. we can use its read/write operations as a means to communicate with the kernel object. that is to say, the current kernel behavior can be adjusted by modifying the documents in/proc. then we can release the memory by adjusting/proc/sys/vm/drop_caches. operations such

/Proc is a virtual document system. we can use its read/write operations as a means to communicate with the kernel object. that is to say, the current kernel behavior can be adjusted by modifying the documents in/proc. then we can release the memory by adjusting/proc/sys/vm/drop_caches. the procedure is as follows:

[Root @ server test] # cat/proc/sys/vm/drop_caches

0

First, the value of/proc/sys/vm/drop_caches. the default value is 0.

[Root @ server test] # sync

Run the sync command manually (description: the sync command runs the sync subroutine. If the system must be stopped, run the sync command to ensure the integrity of the document system. The sync command writes any unwritten system buffer to the disk, including modified I-nodes, delayed block I/O, and read/write ing documents)

[Root @ server test] # echo 3>/proc/sys/vm/drop_caches

[Root @ server test] # cat/proc/sys/vm/drop_caches

3

Set/proc/sys/vm/drop_caches to 3

[Root @ server test] # free-m

Total used free shared buffers cached

Mem: 249 66 182 0 0 11

-/+ Buffers/cache: 55 194

Swap: 511 0 511

Run the free command and find that the current used is 66 MB, free is 182 MB, buffers is 0 MB, and cached is 11 MB. this effectively releases the buffer and cache.

The usage of/proc/sys/vm/drop_caches is described below

/Proc/sys/vm/drop_caches (since Linux 2.6.16)

Writing to this file causes the kernel to drop clean caches,

Dentries and inodes from memory, causing that memory to become

Free.

To free pagecache, use echo 1>/proc/sys/vm/drop_caches;

Free dentries and inodes, use echo 2>/proc/sys/vm/drop_caches;

To free pagecache, dentries and inodes, use echo 3>

/Proc/sys/vm/drop_caches.

Because this is a non-destructive operation and dirty objects

Are not freeable, the user shoshould run sync (8) first.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.