How Linux Computes MemFree

I am trying to understand the use of Linux built-in memory.

Using the top utility and the process file / proc / meminfo, I can see how much virtual memory is used by the process and how much physical memory is available to the system. But it would seem that for any process, virtual memory can be much higher than the physical memory used. Since this is the built-in system memory replacement disabled (SwapTotal = 0)

How does Linux calculate free physical memory? Since it does not seem to take into account everything that is allocated in the virtual memory space.

+7
memory-management linux
source share
2 answers

MemFree in /proc/meminfo - the number of pages free in the distributor of the interlocutor. This allocation buddy is the basic unit for allocating physical memory in the kernel; however, there are many ways that pages can be returned to the buddy allocator when necessary - for example, freeing up empty SLABs, dropping cache / buffer RAM (even if this means PTE is invalid in a running process) or as a last resort by changing things.

In fact, MemFree usually controlled only by 5-10% of the total physical RAM, and any additional free RAM is copied to the cache over time. Thus, MemFree itself is a very incomplete view of the general situation with memory.

As for the virtual memory (VSIZE) of this process, this refers to the sum of the sizes of all mapped memory segments in the process address space. However, not all of them will be physically present - some may be loaded on first access and, as such, will not be registered as used memory, while actually used. Resident size (RSIZE) is a more accurate view, since it registers only those pages that are displayed right now - although it can also be inaccurate if this page is displayed in several virtual addresses (which is very common when considering several processes - shared libraries have the same physical RAM displayed for all processes that use this library)

+12
source share

Try using htop. You will need to install it sudo apt-get install htop or yum install htop , whatever.

It will show you a more accurate idea of ​​memory usage.

Basically, it comes down to "buffers / cache."

 free -m 

Look at the free column in the line of buffers / caches, this is a more accurate idea of ​​what is really available.

  total used free shared buffers cached Mem: 3770 3586 183 0 112 1498 -/+ buffers/cache: 1976 1793 Swap: 7624 750 6874 
+3
source share

All Articles