On a Junos device facing a memory-related issue, the following message is seen:
kernel: %KERN-2: swap_pager_getswapspace(3): failed
This article explains the meaning of this syslog message and provides troubleshooting tips.
Swap memory is a form of virtual memory which is used when an application does not get access to as much physical memory as it needs. Swap memory is seen as a last resort by the application. Seeing high usage of swap memory is an indication of the system not being healthy memory-wise.
Extended high usage of swap memory can result in the swap operation (attempt by the application to access swap memory) failing. In this case, the following message would be seen:
kernel: %KERN-2: swap_pager_getswapspace(3): failed
Use the commands below to view the current usage of swap memory. Additional pointers can be obtained from the output below regarding the cause behind the swap memory usage.
Note: Swap memory is often the victim and not the cause of the problem. Try to isolate the reason behind the usage of swap memory.
show system processes extensive
last pid: 76305; load averages: 0.29, 0.26, 0.23 up 12+08:40:01 00:33:38
370 processes: 5 running, 337 sleeping, 28 waiting
Mem: 99M Active, 3663M Inact, 921M Wired, 492M Buf, 11G Free
Swap: 8192M Total, 8192M Free <-- Notice the usage of swap here. In this case, swap memory is not being used.
PID USERNAME PRI NICE SIZE RES STATE C TIME WCPU COMMAND
11 root 155 ki31 0K 64K CPU2 2 292.9H 100.00% idle{idle: cpu2}
11 root 155 ki31 0K 64K CPU3 3 292.9H 100.00% idle{idle: cpu3}
11 root 155 ki31 0K 64K CPU0 0 292.4H 100.00% idle{idle: cpu0}
11 root 155 ki31 0K 64K RUN 1 292.9H 99.27% idle{idle: cpu1}
10410 root 21 0 1459M 663M nanslp 1 680:29 3.17% chassisd
76303 labroot 21 0 88252K 44196K select 3 0:00 1.27% cli
10431 root 20 0 727M 13272K select 0 30:57 0.00% clksyncd
10551 root 20 0 900M 44620K nanslp 1 15:40 0.00% rep-serverd
10550 root 20 0 900M 44616K nanslp 3 15:27 0.00% rep-clientd
show system virtual-memory | match swap
SWAP 2 1097K - 2 64
SWAPMETA: 288, 2034318, 0, 0, 0
0 swap pager pageins
0 swap pager pages paged in
0 swap pager pageouts
0 swap pager pages paged out
After isolating an application that is consuming higher memory, try to isolate the reason behind that or reach out to JTAC to validate your findings and get a recommendation if restarting that application would help. In many cases, where the existing physical memory on the device is less than what is required, as a last resort an upgrade would be needed in order for the hardware and software to increase available memory for the system.