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

How to use the vmstat command to determine memory usage

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

Share

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

Today, I will talk to you about how to use the vmstat command to determine memory usage. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

The vmstat command summarizes the total active virtual memory used by all processes in the system, as well as the number of real memory page frames on the free list.

Active virtual memory is defined as the number of work segment pages actually available in virtual memory. This number may be greater than the actual number of page frames on the machine, because some active virtual memory pages may have been written out to the paging space.

When determining whether the system is out of memory or if some memory adjustment is needed, run the vmstat command within a set interval and check the pi and po columns in the results report. These two columns indicate the number of paging space pages per second and the number of paging space pages per second. If these values are often non-zero, there may be a memory bottleneck. Don't worry about occasional non-zero values, because page scheduling is the main principle of virtual memory.

# vmstat 2 10kthr memory page faults cpu--r b avm fre re pi po fr sr cy in sy cs us sy id wa 13 113726 124 0 146 151 600 0 521 5533 816 23 13 7 57 03 113643 346 0 2 14 208 690 0 585 2201 866 16 9 2 73 03 113659 135 0 22 108 323 0 516 1563 797 25 7 2 66 0 2 113661 122 03 2 120 375 0 527 1622 871 13 7 2 79 03 113662 128 0 103 134 432 0 644 1434 948 22 7 4 67 15 113858 238 0 35 1 146 422 0 599 5103 903 40 16 0 44 0 3 113969 127 0 5 10 153 529 0 565 2006 823 19 83 70 0 3 113983 125 0 33 5 153 424 0 559 2165 921 25 8 4 63 0 3 113682 121 0 20 9 154 470 0 608 1569 1007 15 8 0 77 0 4 113701 124 0 3 29 228 635 0 674 1730 1086 18 9 0 73

In the sample output above, note the high Icano waiting rate in the output and the number of threads in the blocking queue. Other Iripple O activities may cause Iripple O to wait, but in this special case, the wait is most likely caused by page calls to and from the page space.

To see if there are performance problems with the system's VMM, check the columns under memory and page:

Memory

Provides information about actual and virtual memory.

Avm

The active virtual memory (avm) column represents the number of active virtual memory pages that existed when the vmstat samples were collected. The default policy is the deferred page space policy. Under this strategy, the value of avm may be higher than the number of pages in paging space used. Avm statistics do not contain file pages.

Fre

The fre column shows the average number of free memory pages. A page is an area of 4 KB in real memory. The system maintains buffers for memory pages, called free lists. You can easily access this free list when VMM needs space. The minimum number of pages that VMM leaves on the free list is determined by the minfree parameter of the vmo command.

When an application terminates, all of its working pages are immediately returned to the free list. However, its permanent page (or file) is still in RAM and will not be added back to the free list until it is stolen by VMM for use in other programs. If you delete the corresponding file, its permanent page will also be released.

For this reason, the value of fre may not mean that the process can easily use all real memory. If a page frame is required, the permanent page associated with the terminated application will be handed over to another program first.

If the value of fre is much greater than the value of maxfree, then system bumps are unlikely to occur. The system bump means that the system is calling in and out of the page all the time. However, if the system is experiencing bumps, you can be sure that the fre value is small.

Page

Information about page failure and page scheduling activities. They are averages over a period of time and are given in seconds.

Re

Note: this column is not currently supported.

Pi

The pi column details the number of pages called from the paging space. Paging space is part of the virtual memory that resides on disk. It is used as an overflow when memory is overused. The paging space consists of logical volumes used to store workgroup pages stolen from real memory. A page fault occurs when a process accesses a stolen page, which must be read into memory from the paging space.

There are no absolute numbers to refer to because of differences in hardware configuration, software, and applications. This field serves as a key indicator of paging space activity. If a page call occurs, the page must have an earlier page call out. In a memory-constrained environment, it is also possible that each page call will force another page to be stolen and the page called out.

Po

The po column shows the number of pages called to the paging space (rate). Whenever a page of working memory is stolen, if it still does not reside in the paging space or has been modified, it will be written to the paging space. If it is not accessed again, it remains in the page scheduling device until the process terminates or gives up space. If subsequent address references included in the failure page cause a page fault, then these pages will be called individually by the system. When a process terminates normally, any paging space allocated to the process is freed. If the system reads a large number of permanent pages, you will find an increase in the po column but not a corresponding increase in the pi column. This does not necessarily cause system jolts, but it ensures an investigation of the application's data access patterns.

Fr

The number of pages per second released according to the page replacement algorithm within a certain time interval. When the VMM page replacement routine scans the page frame table (Page Frame. Table,PFT), it uses some conditions to select the page to steal to insert into the free list of available memory frames. This condition contains two types of pages, the work (calculated) and the file (permanent) pages. Just because the page has been released, it doesn't mean that any iUnix O has occurred. For example, if a permanent storage (file) page has not been modified, it will not be written back to disk. If Icano is not required, then minimal system resources are required to release the page.

Sr

The number of pages checked per second according to the page replacement algorithm within a certain time interval. The page replacement algorithm may have to scan many page frames before it can steal enough pages to meet the needs of the page replacement thread. The higher the sr value is than the fr value, the more difficult it will be for the page replacement algorithm to find qualified pages to steal.

Cy

The number of cycles per second in the clock algorithm. VMM uses a technique called the clock algorithm to select pages to replace. This technique uses the access bits of each page to indicate which pages have been used recently. When the page stealer routine is called, it traverses the entire PFT, checking the access bits of each page.

The cy column shows how many times the page replacement code scanned PFT per second. Because inserting a free list does not require a full scan of the PFT, and because all vmstat fields are reported as integers, this field is usually 0.

One way to determine the appropriate number of RAM for your system is to look at the maximum value of avm reported by the vmstat command. Multiply this number by 4K to get the number of bytes, and then compare it with the number of RAM bytes of the system. Ideally, the avm should be less than the total RAM. If not, there may be some virtual memory page scaling. How much page scheduling occurs depends on the difference between the two values. Remember, the concept of virtual memory provides us with the ability to address larger than real memory (some in RAM memory and others in paging space). However, if the virtual memory is much larger than the real memory, it may cause excessive page scheduling, resulting in latency. If avm is less than RAM, page scheduling of the paging space will occur when the RAM is filled with file pages. In this case, adjusting the values of minperm, maxperm, and maxclient reduces the page size of the paging space.

After reading the above, do you have any further understanding of how to use the vmstat command to determine memory usage? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report