I'm trying to host java8 UI application on VPS server (Digital Ocean) with 1GB of RAM. Java is started with -Xms600m -Xmx600m
(startup and max memory usage). Also it runs VNC + mate-core. My assumption is that 400m should be enough for non-java staff and 1GB
is OK for me.
But I experience strange memory problems. With no swap
and swappiness=0
system after some time goes into 90% CPU usage by kswapd0
and system freezes.
I've added swap of 500MB. With same swappiness=0
now top
shows that both almost all physical memory is used plus whole swap too. I was trying to check what is consuming so much memory and see in top
that sum of RES is around 730M
- seems to be as expected.
In my understanding - with such memory usage swap is not needed at all, but actually whole swap of 500М
appears to be consumed - so total memory consumption (physical + swap) appears to be close to 1400M
and I still experience strange freezes and during these moments kswapd0
is the first one in top
.
So ...
- What am I getting wrong here?
- Why "Mem Used + Swap Used" is twice higher than "Sum of RES"?
- Why there is so high Swap usage with
swappiness=0
?
top
sorted down by "RES"
(After hint from @TooTee - added columns SWAP and USED, which is RES+SWAP)
top - 14:12:17 up 14:13, 2 users, load average: 1.40, 3.49, 2.99
Tasks: 115 total, 1 running, 78 sleeping, 0 stopped, 0 zombie
%Cpu(s): 17.6 us, 8.5 sy, 0.0 ni, 65.2 id, 0.2 wa, 0.0 hi, 0.2 si, 8.3 st
KiB Mem : 1009136 total, 66492 free, 881084 used, 61560 buff/cache
KiB Swap: 511996 total, 1056 free, 510940 used. 22580 avail Mem
PID VIRT RES SWAP USED SHR S %CPU %MEM TIME+ COMMAND
3271 3065936 690516 274056 964572 400 S 21.8 68.4 212:57.30 java
1348 298512 46952 78576 125528 6476 S 6.2 4.7 62:43.95 Xvnc4
883 496100 12328 2968 15296 7688 S 0.0 1.2 0:41.00 do-agent
3256 633796 9728 7912 17640 6132 S 1.0 1.0 3:47.81 mate-terminal
1475 544648 5100 5736 10836 3252 S 0.2 0.5 3:37.92 clock-applet
1 77684 2572 116 2688 532 S 0.0 0.3 0:11.74 systemd
1476 493176 2492 4580 7072 44 S 0.0 0.2 0:04.09 wnck-applet
1412 442048 2340 5208 7548 704 S 0.0 0.2 0:06.59 marco
1400 992492 1916 5924 7840 304 S 0.2 0.2 3:30.01 mate-settings-d
1100 111460 1828 440 2268 0 S 0.0 0.2 0:00.00 (sd-pam)
8684 23072 1644 0 1644 24 S 0.0 0.2 0:00.08 bash
409 80244 1268 1172 2440 1152 S 0.0 0.1 0:08.14 systemd-journal
8697 44552 1072 0 1072 388 R 0.2 0.1 0:07.14 top
1434 700512 1024 6876 7900 0 S 0.0 0.1 0:02.43 mate-panel
703 70756 584 524 1108 404 S 0.0 0.1 0:02.32 systemd-resolve
865 31748 512 224 736 436 S 0.0 0.1 0:00.89 cron
8585 107776 464 856 1320 300 S 0.2 0.0 0:00.81 sshd
1506 323368 408 1416 1824 0 S 0.0 0.0 0:00.04 polkit-mate-aut
891 287992 376 792 1168 288 S 0.0 0.0 0:04.66 accounts-daemon
1359 436920 356 7596 7952 0 S 0.0 0.0 0:00.49 mate-session
887 44640 312 780 1092 60 S 0.2 0.0 1:54.70 openvpn
892 263036 180 1112 1292 0 S 0.0 0.0 0:03.61 rsyslogd
1084 107776 176 844 1020 0 S 0.0 0.0 0:00.21 sshd
1231 107776 160 868 1028 0 S 0.0 0.0 0:10.07 sshd
1375 220776 72 716 788 0 S 0.0 0.0 0:00.05 at-spi2-registr
776 43564 48 944 992 0 S 0.0 0.0 0:00.62 systemd-udevd
678 71972 36 696 732 0 S 0.0 0.0 0:00.53 systemd-network
869 50188 36 716 752 0 S 0.0 0.0 0:00.40 dbus-daemon
1358 38572 36 376 412 0 S 0.0 0.0 0:00.10 vncconfig
860 70580 32 692 724 0 S 0.0 0.0 0:00.37 systemd-logind
889 170884 32 7816 7848 12 S 0.0 0.0 0:00.15 networkd-dispat
597 141924 24 576 600 0 S 0.0 0.0 0:00.33 systemd-timesyn
885 28332 24 192 216 0 S 0.0 0.0 0:00.00 atd
944 16412 24 124 148 0 S 0.0 0.0 0:00.00 agetty
925 72296 16 740 756 0 S 0.0 0.0 0:01.69 sshd
945 14888 16 112 128 0 S 0.0 0.0 0:00.04 agetty
1092 76772 4 1180 1184 4 S 0.0 0.0 0:00.03 systemd
1320 63764 4 484 488 4 S 0.0 0.0 0:00.00 sudo
1366 349216 4 784 788 4 S 0.0 0.0 0:00.00 at-spi-bus-laun
1449 281988 4 824 828 4 S 0.0 0.0 0:00.01 gvfs-gphoto2-vo
1460 267396 4 684 688 4 S 0.0 0.0 0:00.01 gvfs-goa-volume
1465 269200 4 696 700 4 S 0.0 0.0 0:00.01 gvfs-mtp-volume
2 0 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
f
key intop
to enable theSWAP
column to see how much swap is each process using. I guess you'll find that the desktop environment is mostly swapped out and/or that a sizable chunk of JVM is on swap as well. You're asking for 600 MiB of heap to be accessible to the Java app, but the JVM also needs memory for its internals, stacks and so on.