A Brief Introduction to manual release of Linux memory

Source: Internet
Author: User
Tags server memory

The release of Linux server memory seems to improve the efficiency of some people, but the actual work is not very satisfactory. Here we will talk about how to do this job, it helps us better understand how the Linux system works.

Volkswagen memory release method

1. First use free-m to view the remaining memory

View plaincopy to clipboardprint?

Linux-8v2i :~ # Free-m

Total used free shared buffers cached

Mem: 3952 2773 178 0 130 1097

-/+ Buffers/cache: 1545 2406

Swap: 2055 0 2055

Linux-8v2i :~ # Free-m

Total used free shared buffers cached

Mem: 3952 2773 178 0 130 1097

-/+ Buffers/cache: 1545 2406

Swap: 2055 0 2055

2. Run the sync command.

Use the sync command to ensure the integrity of the file system. Run the sync command to run the sync subroutine and write all unwritten system buffers to the disk, contains modified I-node, delayed block I/O, and read/write ing files.

View plaincopy to clipboardprint?

Linux-8v2i :~ # Sync

Linux-8v2i :~ # Sync

3. Modify/proc/sys/vm/drop_caches

View plaincopy to clipboardprint?

Echo 3>/proc/sys/vm/drop_caches

Echo 3>/proc/sys/vm/drop_caches

Note:

1>./proc is a virtual file system. We can use its read/write operations as a means of communication with the kernel object. In other words, you can modify the file in/proc to adjust the current kernel behavior. In other words, we can adjust/proc/sys/vm/drop_caches to release the memory.

2>. Official descriptions of drop_caches are as follows:

Writing to this file causes the kernel to drop clean caches, dentries and inodes from memory, causing that memory to becomefree.

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

To 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 shocould run sync first.

3>. the Linux kernel caches the recently accessed file pages in the memory for a period of time. This File Cache is called pagecache.

4. Use free-m to view the remaining memory as follows:

View plaincopy to clipboardprint?

Linux-8v2i :~ # Free-m

Total used free shared buffers cached

Mem: 3952 1773 2325 0 0 80

-/+ Buffers/cache: 1545 2406

Swap: 2055 0 2055

Linux-8v2i :~ # Free-m

Total used free shared buffers cached

Mem: 3952 1773 2325 0 0 80

-/+ Buffers/cache: 1545 2406

Swap: 2055 0 2055

The release of Linux Server Memory is easy.

  1. Linux shell script BASICS (1)
  2. A Brief Introduction to how to obtain the file path of a Linux Process
  3. Detailed introduction to basic learning of Linux shell scripts 8)
  4. Security Configuration for Linux system security improvement
  5. Linux system security improvement-System Optimization

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.