0

One of our Docker hosts is swapping like hell for no reason - at least, no apparent one (it's a Ubuntu 16.04LTS VM). All Docker containers in summary only use ~4 GB of the 12GB RAM total, but the system uses 10GB of physical RAM in addition to 6GB of swap.

What can cause this? The "big ones" are one instance of sonatype/nexus3 and one instance of gitlab/gitlab-ce. When looking at the processes in htop and sorting by MEM%, nothing out of the ordinary appears, especially nothing in the 14GB range that is being "used" somewhere.

xxx@docker-static:~$ free -m
              total        used        free      shared  buff/cache   available
Mem:          12015       10441         563         537        1010         670
Swap:         11670        6623        5047
xxx@docker-static:~$ docker stats --no-stream
CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
18c956010080        0.81%               541.9MiB / 11.73GiB   4.51%               82.1GB / 3.8TB      149GB / 2.25GB      230
35ec9741be74        0.48%               1.887MiB / 11.73GiB   0.02%               22.1MB / 30.1MB     8.82GB / 5.57MB     8
e90b429c45f4        0.00%               68KiB / 11.73GiB      0.00%               10.5MB / 23kB       19.4MB / 11.2MB     1
091fd79b7b3c        19.17%              1.908GiB / 11.73GiB   16.26%              6.36GB / 526GB      985GB / 43.7GB      353
a1e0dd98679f        0.53%               924.2MiB / 11.73GiB   7.69%               83.9GB / 37.5GB     347GB / 9.98GB      182
1d5368d1ce24        0.25%               60.54MiB / 11.73GiB   0.50%               40.1GB / 112GB      102GB / 2.7GB       12
a0aba32126ec        0.00%               56KiB / 11.73GiB      0.00%               17.1MB / 9.48MB     6.25GB / 18.5MB     4
cc9065d65372        0.00%               256KiB / 11.73GiB     0.00%               1.12MB / 92.6kB     3.07GB / 12.3MB     2
92cb16f6bfc8        0.04%               6.031MiB / 11.73GiB   0.05%               13.1TB / 13.1TB     21.6GB / 1.81GB     4
alexander.polomodov
  • 1,060
  • 3
  • 10
  • 14
  • https://serverfault.com/questions/825911/should-i-be-concerned-that-swap-is-being-used-on-a-host-with-nearly-40gb-of-free/825915#825915 – user476052 Jun 29 '18 at 17:13

1 Answers1

0

Most memory status tools only include how much physical ram is being used so the swap ends up hidden. Try this:

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less

Also top -oRES may be more helpful. Since the host can see all the processes even in containers that should list everything. It's possible your memory hog isn't even in one of the containers.

https://www.cyberciti.biz/faq/linux-which-process-is-using-swap/

Jeff Snider
  • 3,252
  • 17
  • 17
  • I tried the shellcommand, the resulting processes occupy only ~6.13 GB of RAM (a list might be in the edit history of this comment, I can't get it to display properly). – Marco Schuster Jul 02 '18 at 09:56
  • The command shows how much of each process is swapped out. ~6 is consistent with the output of `free` in your question. – Jeff Snider Jul 02 '18 at 14:12