Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of the free command in Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what is the use of the free command in Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the use of the free command in Linux" this article.

In a Linux system, the free command displays the usage of system memory, including physical memory, swap memory (swap), and kernel buffer memory.

How to use the Linux free command dafa

Free``-g [View in G] ``free``-m [View in M] second Line (Mem): operating system Angle

Total: the total amount of physical memory.

Used: how much has been used.

Free: how many are available?

Shared: the total amount of memory shared by multiple processes.

Buffers/cached: size of the disk cache.

Line 3 (- / + buffers/cached): application software

Used: how much has been used.

Free: how many are available?

The fourth line is the swap partition SWAP, which is commonly referred to as virtual memory.

Note:

The difference between the used/free of the second line (mem) and the third line (- / + buffers/cache) used/free:

The second line is from the point of view of OS. Because OS,buffers/cached belongs to being used, his available memory is 265m, and his used memory is 217m.

The third line refers to that from an application point of view, buffers/cached is equal to available for applications, because buffer/cached is designed to improve file read performance, and buffer/cached is quickly recycled when the application needs to use memory.

From an application perspective, * * available memory = system free** memory+buffers+cached

Available memory = 265mm 361

When and by which side the memory will be swapped

When the available memory is less than the rated value, a meeting will be held to swap.

View memory information:

The cat`` / proc/meminfo exchange will reduce the number of physical pages used in the system in three ways:

1. Reduce the size of buffers and page cache

two。 Swap out the memory pages of type V of the system

3. Replace or discard the page. (memory pages occupied by Application, that is, insufficient physical memory).

In fact, the small use of swap does not affect system performance.

Both buffers and cached are caches. In order to improve the efficiency of disk access, Linux has made some careful designs and adopted two main Cache modes: Buffer Cach (for disk block read and write) and Page Cache (for file inode read and write). These Cache effectively shorten the time of calling RW by the Cache O system.

Disk operations include logical level (file system) and physical level (disk block). These two kinds of Cache cache logical and physical data respectively.

Page cache is actually aimed at the file system, which is the cache of files, and the data at the file level is cached to page cache. The logical layer of the file needs to be mapped to the actual physical disk, and this mapping is done by the file system. When the data in page cache needs to be refreshed, the data in page cache is given to buffer cache because Buffer Cache is the cache of disk blocks.

Buffer cache is a cache for disk blocks. In the absence of a file system, data that operates directly on the disk will be cached in buffer cache, such as the metadata of the file system will be cached in buffer cache.

Simply put, page cache is used to cache file data, and buffer cache is used to cache disk data. In the case of a file system, the data will be cached to page cache if you operate on the file. If you directly use tools such as dd to read and write to the disk, then the data will be cached to buffer cache.

So when we look at linux, as long as we don't use the swap space of swap, we don't have to worry about having too little memory. If you often use a lot of swap, you may want to consider adding physical memory. This is also the standard for linux to see if there is enough memory.

If it is an application server, generally only look at the second line, + buffers/cache, that is, free has too little memory for the application, so it is time to consider optimizing the program or adding memory.

The above is all the content of the article "what is the use of free commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report