Skip to content

The lxcfs seems to have a Memory Leak #684

@lu-you

Description

@lu-you

lxcfs Version:
lxcfs -v
3.1.2

The Problem describe:

My lxcfs runs for a while,i can see a increase about it memory, and it doesn't seems to be going to recycle, keep increasing;
It will be normal after i must to restart lxcfs

#RSS
#top -H -b -n 1 | grep lxcfs|head -n 1|awk '{print $6}'
1632

#RSS
#top -H -b -n 1 | grep lxcfs|head -n 1|awk '{print $6}'
76.3g

Please help me!

#pmap -x 293408 | grep "anon" | grep "-----" | wc -l
2399
#pmap -x 293408 | more
293408: /usr/bin/lxcfs /var/lib/lxcfs/lxcfs/
Address Kbytes RSS Dirty Mode Mapping
0000556779200000 16 16 0 r-x-- lxcfs
0000556779404000 4 4 4 r---- lxcfs
0000556779405000 4 4 4 rw--- lxcfs
000055677a289000 2844 2064 2064 rw--- [ anon ]
00007fc7a8000000 1588 372 372 rw--- [ anon ]
00007fc7a818d000 63948 0 0 ----- [ anon ]
00007fc7ac000000 1540 4 4 rw--- [ anon ]
00007fc7ac181000 63996 0 0 ----- [ anon ]
00007fc7b4000000 2448 652 652 rw--- [ anon ]
00007fc7b4264000 63088 0 0 ----- [ anon ]
00007fc7bc000000 2012 4 4 rw--- [ anon ]
00007fc7bc1f7000 63524 0 0 ----- [ anon ]
00007fc7c4000000 6840 132 132 rw--- [ anon ]
00007fc7c46ae000 58696 0 0 ----- [ anon ]
00007fc7cc000000 9592 972 972 rw--- [ anon ]
00007fc7cc95e000 55944 0 0 ----- [ anon ]
00007fc7d4000000 7092 2836 2836 rw--- [ anon ]
00007fc7d46ed000 58444 0 0 ----- [ anon ]
00007fc7dc000000 7064 2224 2224 rw--- [ anon ]
00007fc7dc6e6000 58472 0 0 ----- [ anon ]
00007fc7e4000000 3836 364 364 rw--- [ anon ]
00007fc7e43bf000 61700 0 0 ----- [ anon ]
00007fc7ec000000 5276 1160 1160 rw--- [ anon ]
00007fc7ec527000 60260 0 0 ----- [ anon ]
00007fc7f0000000 8624 136 136 rw--- [ anon ]
00007fc7f086c000 56912 0 0 ----- [ anon ]
00007fc7f8000000 7776 2160 2160 rw--- [ anon ]
00007fc7f8798000 57760 0 0 ----- [ anon ]
00007fc7fc000000 11728 4748 4748 rw--- [ anon ]
00007fc7fcb74000 53808 0 0 ----- [ anon ]
00007fc800000000 556 4 4 rw--- [ anon ]
00007fc80008b000 64980 0 0 ----- [ anon ]
00007fc808000000 2844 1664 1664 rw--- [ anon ]
00007fc8082c7000 62692 0 0 ----- [ anon ]

#systemctl cat lxcfs.service
#/lib/systemd/system/lxcfs.service
[Unit]
Description=FUSE filesystem for LXC
ConditionVirtualization=!container
Before=lxc.service
Documentation=man:lxcfs(1)

[Service]
Environment="LXCFS=/var/lib/lxcfs/lxcfs/"
#Environment="INFO_FROM_ENV_PREFIX=COLOCATION"
ExecStartPre=/bin/mkdir -p $LXCFS
ExecStart=/usr/bin/lxcfs $LXCFS
ExecStartPost=-/bin/bash /usr/local/lxcfs/bin/container_remount_lxcfs.sh
KillMode=process
Restart=on-failure
ExecStopPost=-/bin/fusermount -u $LXCFS
Delegate=yes

[Install]
WantedBy=multi-user.target

#cat /usr/local/lxcfs/bin/container_remount_lxcfs.sh
#!/bin/bash

PROCS="cpuinfo diskstats loadavg meminfo stat uptime"
if [ "$LXCFSX"X == ""X ]; then
LXCFS=/var/lib/lxcfs/lxcfs/
fi
LXCFS_DIR=$(dirname $LXCFS)

containers=$(docker ps |grep -v '"/pause"'|awk '{print $1}'|grep -v CONTAINER)
for ctn in $containers; do
echo "container_remount_lxcfs.sh: check $ctn"
docker inspect -f '{{.HostConfig.Binds}}' $ctn | egrep "$LXCFS_DIR[/]:" > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "container_remount_lxcfs.sh: try to remount $ctn"
pid=$(docker inspect -f '{{.State.Pid}}' $ctn)
if [ $? -eq 0 ]; then
for file in $PROCS; do
nsenter --target $pid -a -- umount -l "/proc/$file"
nsenter --target $pid --mount -- mount -B "$LXCFS/proc/$file" "/proc/$file"
done
nsenter --target $pid -a -- umount -l "/sys/devices/system/cpu/online"
nsenter --target $pid --mount -- mount -B "$LXCFS/sys/devices/system/cpu/online" "/sys/devices/system/cpu/online"
fi
fi
done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions