Updated: October 28, 2024 |
Display io-sock virtual memory statistics
vmstat [--libxo] [-l] [-mz] [-w wait] [wait]
QNX Neutrino
The vmstat utility that QNX Neutrino provides is adapted from FreeBSD and supports both a subset of the standard options and the -l (el) QNX Neutrino extension.
For descriptions of standard options, see the FreeBSD documentation (https://www.freebsd.org/cgi/man.cgi?query=vmstat&sektion=8&manpath=FreeBSD+13.0-RELEASE+and+Ports).
Combine with -z or -m to automatically display any memory allocation changes. Enter command characters to select which statistics to display. See Detecting memory allocation changes.
The vmstat utility displays virtual memory statistics in the kernel. When you use it with io-sock, because the kernel is simulated, the only statistics it provides are those related to networking features.
The default option for the version of vmstat that QNX Neutrino provides is -m, which displays reports on the memory used by the io-sock dynamic memory allocator (malloc()), by type. It does not support -a, which is the default option for the standard version of vmstat.
For the QNX Neutrino version of vmstat, to use -w (which pauses a specified number of seconds between displaying statistics), you must also specify -l.
The -l (el) option allows you to observe memory allocation changes and is particularly useful for debugging memory leaks. Measurement starts when vmstat starts with -l and refreshes after one second (or the interval set by -w). If you enter the t command and the memory allocation has not changed, nothing is reported.
The standard vmstat option -m displays the dynamic memory usage statistics and -z reports memory used by the io-sock zone allocator (Universal Memory Allocator or UMA), by zone. The -l (el) QNX Neutrino extension allows you to adjust usage statistics to show, for example, usage from the start of monitoring until the current state of usage, or usage from the last refresh until the current state.
The output uses the following terms to describe the output:
After you start vmstat with -l (el), you can enter the following commands to control the output:
The following example illustrates how you can use vmstat to check for memory leaks.
The vmstat utility is started with -lm. The F command resets the starting point for monitoring, and then the f command displays the change between the starting point and now. Because the count is reset, no statistics are displayed:
F Copy now->first f Tue Apr 6 15:28:44 2021 (first->now) delta Type InUse ( Delta) MemUse HighUse Requests Size(s)
After mounting a driver (e.g., mount -T io-sock ixgbe), entering f displays the change in memory allocation generated by the mount task:
f Tue Apr 6 15:28:48 2021 (first->now) delta Type InUse ( Delta) MemUse HighUse Requests Size(s) ifaddr: 32 ( 11) 12K 12K 87 16,32,64,256,512,2048,4096 ifnet: 6 ( 1) 11K 11K 11 128,2048 lltable: 16 ( 4) 4K 4K 36 256 BPF: 5 ( 1) 2K 2K 10 256 igmp: 5 ( 1) 1K 1K 10 128 busdma: 49209 ( 49209) 67589K 67589K 295254 64,128,2048 linker: 12 ( 3) 3K 3K 103 16,32,512 temp: 23 ( 2) 1K 1K 33744 16,32,64,65536 module: 85 ( 2) 11K 11K 95 128 sysctloid: 1864 ( 1561) 97K 97K 9682 16,32,64,128,256 mld: 3 ( 1) 1K 1K 8 128 ip6ndp: 4 ( 1) 1K 1K 9 64,256 resmgr: 4 ( 4) 7K 7K 47 128,2048,4096 nexusdev: 12 ( 9) 2K 2K 57 16,128 bus: 127 ( 15) 14K 14K 273 16,32,64,128,256 eventhandler: 69 ( 2) 7K 7K 79 64,128 kobj: 43 ( 3) 172K 172K 64 4096 rman: 20 ( 14) 3K 3K 90 32,128 LRO: 16 ( 16) 320K 320K 96 8192,32768 iflib: 101 ( 101) 1209K 1209K 630 64,256,512,1024,8192,16384,32768 ix: 11 ( 11) 37K 37K 11 1024,2048,4096
After unmounting the driver (e.g., umount -f /dev/io-sock/devs-ixgbe.so), entering f displays no statistics (i.e., no change), which indicates that the memory was released:
f Tue Apr 6 15:28:55 2021 (first->now) delta Type InUse ( Delta) MemUse HighUse Requests Size(s) ix: UNLOADED (Check logs for 'Warning: memory type ix leaked memory on destroy') x exit! #
Because the driver destroyed the ix memory type, vmstat can no longer compare it to counts in the current interval.
To detect whether any ix memory leaked when the driver destroyed that memory type, enter the following grep search of log information (after exiting the interactive monitor, or in another terminal). If there is no leak, no log is generated:
# slog2info | grep "Warning: memory type ix leaked memory on destroy" Dec 12 18:54:21.685 io_sock.77291564 main_buffer 60 Warning: memory type ix leaked memory on destroy (11 allocations, 37888 bytes leaked).