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