I have a docker swarm CE setup in EC2. I have two nodes. 1 manager and 1 worker. The host instance type is Alpine Linux.
In the Manager host the Memory usage is:
~ $ free -m
total used free shared buffers cached
Mem: 7972 4996 2975 715 178 2857
-/+ buffers/cache: 1960 6011
Swap: 0 0 0
~ $
Now when i login the container,
~ $ docker exec -it c7cc255aca1f /bin/bash
[root@c7cc255aca1f /]#
And see the memory utilization:
[root@c7cc255aca1f /]# free -m
total used free shared buff/cache available
Mem: 7972 1654 2970 715 3347 5269
Swap: 0 0 0
[root@c7cc255aca1f /]#
Kindly help me how to clear the buff/cache or cached ?
To clear the cache please see https://unix.stackexchange.com/questions/17936/setting-proc-sys-vm-drop-caches-to-clear-cache.
By the way why do you want to drop the cache? I am certain you do not want to drop the cache (unless you are doing some read benchmark, like with dd
).
Your cache will be freed up as soon as a process needs memory. It is designed to use all available memory. Under Linux it is completely OK to run with no "free" memory (the one free
refers to as "free") as long as you have enough available
(or total
-- buffers/cache
is enough).
It is also highly recommended to add SWAP (even if you do not want to swap) to prevent OOM situations. Just create a swapfile somewhere, and set the vm.swappiness
sysctl
parameter to 0
so it won't be used if there is still RAM memory available.
While the kernel may evict buffers/cache for containers as needed, it cannot evict tmpfs.
LXCFS reports tmpfs as buffers/cache.
Systemd-journald writing logfiles in /run (a tmpfs), will be charged to the buffers/cache - and no amount of dumping buffers will free ram up once journald eats all ram. When OOMkiller strikes, it might take out a process or the entire container due to tmpfs eating all ram.
You can clear your journal files to reduce the size:
journalctl --vacuum-time=2days
Or you can clear based on size:
journalctl --vacuum-size=100M
Note that older versions of journalctl do NOT offer --vacuum functions. I am not aware how to cleanly clear the logfiles (other than deleting them by hand?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With