Gnome 3.36.2 leaking memory and CPU in 20.04

I can confirm that I'm also experiencing the same memory leak with gnome-shell with a Ryzen 7 machine and Radion R9. After up-times approach roughly 2 days, I can visibly notice the lag the OP is experiencing. In addition, if I compare the memory of the process from the start, I will notice that it has climbed significantly and is still climbing.

A temporary workaround is ALT+F2+r, but really they should fix this. Especially if your working on a server which is left running all the time.

Edit: It seems like the memory leak is caused by gnome-shell animations and interactions. So if you do something like constantly minimise and maximise a window, or keep summoning and dismissing the activities view, you can see gnome-shell memory start to increase. It may appear to fluctuate for a while, but eventually the maximum amount of memory it uses will slowly rise and never fall.


I'm having the same problem; gnome-shell uses more and more memory. Slowing down animations and using up memory for nothing.

Since probably nobody will fix the error anyway, I implemented the following "fix" for myself:

Letting this script run every 15 minutes. When the memory usage of the gnome-shell process for the current user exceeds a usage percentage (limit) of 2% it will automatically restart the gnome-shell process (without loosing any work or applications, it's the same as running Alt+F2 and then R).

#!/bin/sh
    
logfile=/home/$(whoami)/bin/gnome-auto-restart.log
    
# memory limit of the gnome-shell-process as a percentage
limit="2.0"
    
restartShell() {
    export DISPLAY=:1
    busctl --user call org.gnome.Shell /org/gnome/Shell org.gnome.Shell Eval s 'Meta.restart("Restarting...")' > /dev/null 2>&1
}
    
mem=$(ps -o pid,user,%mem,command ax|grep -i /usr/bin/gnome-shell |grep -i $(whoami)|sort -b -k3 -r|head -n1|tr -s " "|cut -d" " -f3)
    
echo "$(date) checking memory usage percentage of gnome-shell ($mem) against $limit" >> $logfile
    
if awk 'BEGIN {exit !('$mem' >= '$limit')}'; then
    echo "$(date) --> limit reached, restarting gnome-shell" >> $logfile
    restartShell
else
    echo "$(date) --> limit not reached" >> $logfile
fi

I'm restarting the gnome-shell every night, too, as my workstation is running 24/7. And I'm thinking about restarting it at noon during lunch...