Linux cache memory Cache Memory detailed

  
 

Linux and Win memory management, will try to cache memory to improve read and write performance, usually called Cache Memory. Sometimes you will find that no program is running, but using the top or free command to see the available memory free items will be very small, then look at the system's /proc/meminfo file, you will find a Cached Memory: enter cat /proc/meminfo See:

MemTotal: 16425996 kBMemFree: 5698808 kBBuffers: 380904 kBCached: 9389356 kBSwapCached: 212 kBActive: 6569200 kBInactive: 3725364 kBHighTotal: 0 kBHighFree: 0 kBLowTotal: 16425996 kBLowFree: 5698808 kBSwapTotal: 8273464 kBSwapFree: 8273252 kBDirty: 980 kBWriteback: 0 kBAnonPages: 524108 kBMapped: 24568 kBSlab: 381776 kBPageTables: 7496 kBNFS_Unstable: 0 kBBounce: 0 kBCommitLimit: 16486460 kBCommitted_AS: 2143856 kBVmallocTotal: 34359738367 kBVmallocUsed: 267656 kBVmallocChunk: 34359469303 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0Hugepagesize: 2048 kB

free index command in the memory Description: total used free shared buffers cachedMem: 16425996 10727220 5698776 0 380904 9389832 - /+ buffers /cache: 956484 15469512Swap: 8273464 212 8273252

The first line uses a global perspective to describe the memory usage of the system:

total——total physical memory

used——used memory, in general this value will be larger, Because this value includes the memory used by the cache+ application

free—— completely unused memory

shared——application shared memory

buffers—&mdash Cache, mainly used for directory, inode value, etc. (ls large directory can see this value increase)

cached——cache for open files

Summary:

total = used + freeused = buffers + memory use cached (maybe add shared also)

the second line description of the application:

former value represents -buffers /cache & mdash ;— the memory size used by the application, used minus the cache value

The last value indicates +buffers/cache—— all available memory size for the application, free plus cache value

Summary:

-buffers/cache=used-buffers-cached+buffers/cache=free+buffers+cached

The third line indicates the swap :

used——has been used

free—— unused is Cache Memory:

When you read and write files, Linux kernel In order to improve read and write performance and speed, the file will be cached in memory, which is the Cache Memory. Even if your program finishes running, Cache Memory will not be released automatically. This will cause you to read and write files frequently on Linux systems, you will find that there is very little physical memory available.

In fact, this cache memory is automatically released when you need to use memory, so you don't have to worry about no memory available. If you want to manually release the Cache Memory, there is a way.

how to release the Cache Memory (cache memory):

with the following command can be released Cache Memory: To free pagecache: echo 1 & gt; /proc /sys /vm /drop_cachesTo free dentries and inodes : echo 2 & gt; /proc /sys /vm /drop_cachesTo free pagecache, dentries and inodes: echo 3 & gt; /proc /sys /vm /drop_caches

Note that, preferably before releasing the sync bit, to prevent loss of data .

Summary: Personal experience that there is no need to manually release, this memory management method is also one of the wins than win! Because of Linux's kernel memory management mechanism, it is generally not necessary to specifically release the used cache. These cached content can improve the speed of reading and writing files and disks.

Copyright © Windows knowledge All Rights Reserved