Summary of memory cleanup and release commands in Linux systems

Source: Internet
Author: User
Tags file system memory usage

# cleanup steps

# Pre-cleanup memory usage

The code is as follows:

Free-m

# Start Cleaning up

The code is as follows:

Echo 1 >/proc/sys/vm/drop_caches

# After cleaning up memory usage

The code is as follows:

Free-m

Complete!

# View the number of memory lines command:

Copy Code

The code is as follows:

Dmidecode | Grep-a16 "Memory device$"

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

Sync

# before releasing the best sync, to prevent data loss. Because the Linux kernel mechanism, generally do not need to deliberately release the cache already used. These cache content can increase the file and read and write speed.

# first tell me how to look at the free command memory

The code is as follows:

$free

Total used free shared buffers Cached

mem:1535052 918928 616124 0 2512 82964

-/+ buffers/cache:833452 701600

swap:0 0 0

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

total--Total Physical Memory

used--has used memory, this value will be larger in general, because this value includes the memory used by the cache+ application

free--memory that is completely unused

shared--Application Shared Memory

buffers--cache, mainly used in the directory, Inode value, etc. (LS Large directory can see this value increase)

cached--cache, for open files

Total = used + Free

Used = buffers+cached (maybe add shared also)

The second line describes the application's memory usage:

The previous value represents the memory size used by the-buffers/cache--application, used minus the cached value

The latter value represents the amount of memory that +buffers/cache--can use for the application, free plus the cached value

-buffers/cache=used-buffers-cached

+buffers/cache=free+buffers+cached

The third line indicates the use of swap:

used--already used

free--not used

Manually perform the sync command (description: The sync command runs the Sync subroutine.) If the system must be stopped, run the sync command to ensure the integrity of the file system. The Sync command writes all of the unused system buffers to disk, including modified I-node, deferred block I/O, and read-write mapping files.

Echo 3 >/proc/sys/vm/drop_caches

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 described below

The code is as follows:

/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 which memory to become

Free.

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

# Original Link: http://levi.cg.am/?p=3224

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.