Memory leak on cgroup item access in liblxc1 3.0.3 / bionic
Required information
- Distribution: Ubuntu
- Distribution version: 18.04
- The output of
lxc-start --version: 3.0.3
Issue description
We're using go-lxc to harvest metrics from our containers. A steady memory growth (RSS) of our service was visible after upgrading some machines from Ubuntu 16.04 to Ubuntu 18.04.
After some debugging it turned out that it is not a go problem and the same binary works fine on Ubuntu 16.04 / liblxc 2.0.11 and also on Ubuntu 20.04/ liblxc 4.0.2.
The bug only affects the current bionic liblxc1 package version 3.0.3.
Steps to reproduce
- Create a container "controller" and start it. Details are not important, container can be idle.
- Run the provided test program on the host
- Monitor the test programs RSS usage (htop etc.)
- Slow but steady memory growth is visible
Test Program
package main
import "gopkg.in/lxc/go-lxc.v2"
func main() {
lxcroot := lxc.DefaultConfigPath()
for {
cont, err := lxc.NewContainer("controller", lxcroot)
if err != nil {
panic("No container")
}
cont.CgroupItem("memory.usage_in_bytes")
cont.Release()
}
}
go run lxc-memtest.go
Problem is unrelated to the concrete cgroup item name, also convenience method for memory, swap are affected. Various versions of go-lxc or go compiler had no impact.
I found more debugging time and was able to test against liblxc1 3.0.4 from ubuntu eon. This version is not affected so i guess the backported cgroup handling from 3.0.4 helps.
How to proceed? It's no longer a bug because you fixed it in 3.x and also 4.x but it's instead a distribution specific problem.
As this is distro specific problem and it is about Ubuntu 18.04 it's not actual anymore. Let's close this.
If you have anything else or if the problem is actual, @towe75 please feel free to reopen it.