Linux memory management, in fact, is very similar to Windows Memory Management, all of which use the concept of virtual memory. Speaking of this, we have to scold ms, why do we still use pagefile when there is a lot of physical memory. so we often have to argue with a group of people about the size of pagefile and how to allocate it. in Linux, we don't have to argue about the size of swap. I personally think, it is enough to set up a m swap. What should I do if the M swap is not enough? You can only say that you still need to add memory, or check whether your application actually has a memory leak. The night is deep, so I will not talk nonsense again.In Linux, we usually use command free to view memory. [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: Row 2 (MEM ): Total: total physical memory size. Used: used. Free: available. Shared: The total memory shared by multiple processes. Buffers/cached: disk cache size. Row 3 (-/+ buffers/cached ): Used: used. Free: available. The fourth line won't be explained much. Differences: The difference between used/free of the second row (MEM) and used/free of the third row (-/+ buffers/cache. The difference between the two is that from the usage perspective, the first line is from the OS perspective, because for OS, buffers/cached is used, so its available memory is 8908kb, the used memory is kb, including the + buffers + cached used by the kernel (OS) + application (x, Oracle, etc. The third line indicates that, from the application perspective, for applications, buffers/cached is equivalent to available, because buffer/cached is designed to improve file read performance, when the application needs to use the memory, buffer/cached will be quickly recycled. From the application perspective, the available memory = system free memory + buffers + cached. For example: 185656 = 8908 + 21280 + 155468 Next, we will explain when the memory will be exchanged and by which side. When the available memory is less than the rated value, a meeting will be held for exchange. Rating (rhel4.0 ): # Cat/proc/meminfo Switching reduces the number of physical pages used in the system in three ways: 1. Reduce the buffer and page cache size, 2. swap out the V-type memory page of the system, 3. Swap out or discard the page. (The Memory Page occupied by the application, that is, the physical memory is insufficient ). In fact, using swap in a small amount affects the system performance.
|