Get the App
SLTechnology News&Howtos  ›  Servers  › 

Using top and free commands to view the free memory in the system in CentOS

Shulou Source: shulou.com Published: 2022-06-01 18:32:59 09月30日 Update

This article will explain in detail about CentOS in the use of top and free commands to view the free memory in the system, the content of the article is of high quality, so the editor will share it for you to do a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

So what you see when you execute the top command

[root@linuxzgf ~] # top

Mem: 8174492k total, 7124268k used, does not mean that your application has used 7.1g of memory, this 7.1g contains: application memory + buffer + cached memory, need to be checked with the free command.

Here is an example (in MB):

[root@linuxzgf] # free-m

Total used free shared buffers cached

Mem: 7982 6811 1171 0 350 5114

-/ + buffers/cache: 1346 6636

Swap: 16935 11 16924

[root@linuxzgf ~] #

In this example, the application uses only 1346MB memory, and 6636MB free memory is available.

Some simple calculation methods:

Physical used memory = actual used memory-buffer-cache

= 6811m-350m-5114m

Physical free memory = total physical memory-actual used memory + buffer + cache

Application free memory = total physical memory-actual used memory

Application used memory = actual used memory-buffer-cache

Original explanation: go to the Internet:

The basic principle of Linux is that no resources should be wasted. So the core uses as much RAM as possible to cache information from local and remote file systems. When the system does read and write operations, the data related to the currently running process will be stored in RAM as much as possible. The cache reported by the system is the sum of buffering and page caching. Instead of being reclaimed at the end of a process (you may soon start another process and need the same data), the cache is recycled on demand-for example, when you start a process that requires a lot of memory, the Linux core reclaims the cache from memory and allocates the resulting memory to the new process.

About CentOS in the use of top and free commands to view the free memory in the system is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Memory cache idle system application program process application buffer command actual physics example content data article time more core knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MySQL Docker Microsoft NVidia