Introduction: Linux is not as convenient as the memory in Windows, and there is the new concept of swap, so know how to see the Linux memory has a certain significance.
View memory under Linux We generally use command free
[Root@nonamelinux ~]# Free
Total used free shared buffers Cached
mem:386024 377116 8908 0 21280 155468
-/+ buffers/cache:200368 185656
swap:393552 0 393552
The following is an explanation of these values:
Second line (MEM):
Total: The amount of physical memory.
Used: How big it has been used.
Free: How many are available.
Shared: The total amount of memory shared by multiple processes.
Buffers/cached: The size of the disk cache.
Third line (-/+ buffers/cached):
Used: How big it has been used.
Free: How many are available.
The line four is not much explained.
Difference:
The difference between the used/free of the second line (MEM) and the third row (-/+ Buffers/cache) used/free.
The difference between the two is that the first line is from the OS point of view, because for os,buffers/cached is used, so his available memory is 8908KB, the used memory is 377116KB, which includes, the kernel (OS) uses + Application (X, oracle,etc) used by +buffers+cached.
The third line refers to the application from the point of view of the application, buffers/cached is equal to available, because buffer/cached is to improve the performance of file read, when the application needs to use memory, the buffer/cached will be quickly recycled.
So from an application perspective, the available memory = System Free memory+buffers+cached.
As in the previous example:
185656=8908+21280+155468
Then explain when memory will be exchanged and by what side.
When the available memory is less than the rated value, the meeting is exchanged.
How to look at the rating (RHEL4.0):
#cat/proc/meminfo
Swapping will reduce the number of physical pages used in the system in three ways:
1. Reduce buffer and page cache size,
2. Swap the System V type of memory page out,
3. Swap or discard the page. (The memory page that application occupies, that is, insufficient physical memory).
In fact, a small amount of swap use does not affect system performance.
Here is the difference between buffers and cached.
Buffers refers to the size of the buffer used to make a block device, he only records the file system metadata and tracking in-flight pages.
Cached is used to buffer files.
That is to say: buffers is used to store, what content in the directory, permissions and so on.
and cached is directly used to memorize the files we open, if you want to know if he is really effective, you can try, execute two times command #man X, you can obviously feel the second start of a lot faster.
Experiment: Doing it on a machine that doesn't have any applications can be seen more clearly. Remember the experiment can only do once, if you want to do more please change a filename.
#free
#man X
#free
#man X
#free
You can compare free to show the size of the buffers.
Another experiment:
#free
#ls/dev
#free
You compare the size of two, of course, this buffers is always increasing, but you have LS, the increase speed will become faster, this is the difference between the buffers/chached.