About Linux cachemory

Source: Internet
Author: User
Different from Windows in Linux, CacheMemory exists. sometimes you may find that no program is running, but top or fre is used.

Different from Windows, Linux has a Cache Memory. sometimes you may find that no program is running, but the top or free command shows that the available Memory is very small.

What is Cache Memory?

Cache Memory is also called Cache Memory. when you read and write files, the Linux kernel caches the files in the Memory to improve the read and write efficiency and speed. this part of Memory is the Cache Memory. The Cache Memory will not be automatically released even after your program runs. This will cause the Linux system program to read and write files frequently, you will find that the available physical memory is very small.

Linux Memory management mechanism generally does not need to manually release the used Cache Memory. These Cache Memory can increase the file read/write speed. In fact, Cache Memory is automatically released when you need to use the Memory, so you don't have to worry about no Memory available. You can also manually release the Cache Memory.

Use the free command to view memory usage

 

[Root @ phpally ~] # Free
Total used free shared buffers cached
Mem: 8058600 1844136 6214464 0 49492 1117336
-/+ Buffers/cache: 677308 7381292
Swap: 490488 0 490488

 

  • Total-total physical memory
  • Used-memory used. Generally, this value is relatively large because it includes the memory used by the cache + application.
  • Free-completely unused memory
  • Shared-application shared memory
  • Buffers-cache, mainly used for directories and inode values (this value can be seen in large ls directories)
  • Cached-cache for opened files
  • -Buffers/cache-memory size used by the application, used minus the cache value
  • + Buffers/cache-memory size for all available applications, free plus cache value

The first line describes the memory usage of the system from a global perspective, the second line describes the memory usage of the application, and the third line shows the usage of swap.

Calculation method

  • Total = used + free
  • Used = buffers + cached (maybe add shared also)
  • -Buffers/cache = used-buffers-cached
  • + Buffers/cache = free + buffers + cached

Manual release of Cache Memory

 

 

[Root @ phpally ~] # Sync

To free pagecache:
[Root @ phpally ~] # Echo 1>/proc/sys/vm/drop_caches

To free dentries and inodes:
[Root @ phpally ~] # Echo 2>/proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:
[Root @ phpally ~] # Echo 3>/proc/sys/vm/drop_caches

 

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.