emersion / mako

A lightweight Wayland notification daemon
https://wayland.emersion.fr/mako
MIT License
2.22k stars 139 forks source link

Consumes a lot of memory #405

Open roman-kiselenko opened 2 years ago

roman-kiselenko commented 2 years ago

mako 1.6-1 Consume a lot of memory, accourding to htop it's almost 1.7 GB, sometimes it's more than 2 GB.

image image

sway 1:1.6.1-2 I've rebooted and restart wm.

roman-kiselenko commented 2 years ago

image

Now it's 8 GB and grows. There is memory leak somewhere.

roman-kiselenko commented 2 years ago

Looks like mako-git v1.6.r11.gddc1849-1 from git doesnt have such problem.

cristicc commented 2 years ago

I noticed a similar issue using the following environment:

$ pacman -Q mako sway
mako 1.6-3
sway 1:1.7-2

This seems to be related to https://github.com/emersion/mako/issues/265. I made a script that can be used to quickly confirm the memory leaks:

$ sh <<'EOF'
killall mako
notify-send test-start test-start-body
pid=$(pgrep mako)
[ -n "${pid}" ] || exit 1

sleep 1
printf "\nInitial mem status for pid %d\n" ${pid}
grep '^Vm\(Size\|RSS\):' /proc/${pid}/status

iter=10
printf "\nTurning off displays for %d seconds\n" ${iter}
sleep 2
swaymsg "output * disable"
sleep 5

while [ $((iter=iter-1)) -ge 0 ]; do
    for iter2 in 1 2 3; do
        sleep 0.33;
        notify-send "test${iter}-${iter2}" "test${iter}-${iter2} message"
    done
done

swaymsg "output * enable"
sleep 3
makoctl dismiss -a

printf "\nFinal mem status for pid %d\n" ${pid}
grep '^Vm\(Size\|RSS\):' /proc/${pid}/status
EOF

After just 10 seconds of using notify-send with all displays disabled, the memory leak for a freshly started mako process reaches ~500 MB:

Initial mem status for pid 888578
VmSize:   179976 kB
VmRSS:     14688 kB

Turning off displays for 10 seconds

Final mem status for pid 888578
VmSize:   676484 kB
VmRSS:    511184 kB