Linux Memory Cleanup Release command

Source: Internet
Author: User

Linux memory Cleanup/release commands


1. Memory usage before cleanup

Free-m

2. Start cleaning up
Echo 1 >/proc/sys/vm/drop_caches

3. Memory usage after cleanup
Free-m

4. Complete!

To view the number of memory bars command:

Dmidecode | Grep-a16 "Memory device$"

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

# Sync

# echo 1 >/proc/sys/vm/drop_caches
Echo 2 >/proc/sys/vm/drop_caches
Echo 3 >/proc/sys/vm/drop_caches


cache release:
to free Pagecache:
echo 1 >/proc/sys/vm/drop_caches
to free dentries and inodes:

to free Pagecache, dentries and inodes: BR style= "Line-height:normal;" >

Note that it is best to sync before releasing to prevent data loss.

Because of the kernel mechanism of Linux, it is generally not necessary to deliberately release the cache that is already in use. These cache contents can increase the file and read and write speed.
Let's see how the free command looks at memory.


[[email protected] proc] # Free

Total used free shared buffers Cached
mem:515588 295452 220136 0 2060 64040
-/+ buffers/cache:229352 286236
swap:682720 112 682608


The first line describes the memory state used by the system in a global perspective:

Total--Overall physical memory

used-memory is used, this value is generally larger because the value includes the

cache+ memory used by the application Free --Completely unused memory


GKFX-Application shared memory

buffers-cache, mainly used for directory aspects, Inode value, etc. (LS large directory can see a value increase)

cached--cache, for files that have been opened

Note
Total=used+free
Used=buffers+cached (maybe add shared also)

The second line describes the memory usage of the application:
The previous value indicates the memory size used by the-buffers/cache--application, used minus the cached value
The latter value indicates the amount of memory +buffers/cache--all available to the application, free plus the cached value
Note
-buffers/cache=used-buffers-cached
+buffers/cache=free+buffers+cached

The third line represents the use of swap:

used--Used

Free--not used


Perform the sync command manually (description: Sync command runs the Sync subroutine. If you must stop the system, run the Sync command to ensure the integrity of the file system. The Sync command writes all the non-writable system buffers to disk, including modified I-node, deferred block I/O, and read-write mapping files.


[[email protected] test] # echo 3 >/proc/sys/vm/drop_caches
[[email protected] test] # cat/proc/sys/vm/drop_caches
3


! Set the/proc/sys/vm/drop_caches value to 3

The usage of/proc/sys/vm/drop_caches is explained 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 the memory to become
Free.

To free Pagecache with 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


Summary: Read carefully before using the Bo Master command.

This article from "Li Shilong" blog, declined reprint!

Linux Memory Cleanup Release command

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.