You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into this as well, which led me on a wild goose chase trying to hunt down a memory leak in my application. Currently docker stats is showing my container is using 1008MiB, but the memory usage for the entire host reported by free -m is only 441MiB.
Specifically the problem is with dentry. My application will spool request bodies to /tmp, so I have a large number of short-lived files. dentry will cache information about these files, which is not cleared once the file is deleted, meaning dentry will continue growing until the kernel decides to clear it.
I've found that setting up /tmp as a bind mount prevents dentry from inflating, so that's my current workaround to keeping container memory usage at a useful value.
I have an empty ubuntu image on cgroups v1:
I run
/bin/bash
in it and it occupies1.312MiB
according todocker stats
.I then install python (with
apt
) and dodu --inodes -d1 /
docker stats
now shows16.32MiB
.I do not have any process (except bash), so what happened?
I check
memory.stat
and seeSo, my RSS is 480 KB, what occupies 16 megabytes?
I check
memory.usage_in_bytes
:17113088
And
memory.kmem.usage_in_bytes
is16547840
It seems that container memory is used by kernel.
I check slabs
You see: kernel memory is occupied with inode_cache and dentry and overlay inodes.
Lets purge it:
echo 2 > /proc/sys/vm/drop_caches
Much better
And
docker stats
now shows1.863MiB
.Conclusion: If you list some directories and files in container, your memory usage grows.
Docker charges container for slabs (inode cache).
But why? Shouldn't this information be excluded from
docker stats
MEM USAGE like you do it with page cache?I know that cache will be purged as needed, but this situation makes
docker stats
almost useless!The text was updated successfully, but these errors were encountered: