GNOME Bugzilla – Bug 766353
Huge memory usage related with changing background
Last modified: 2016-08-15 14:33:15 UTC
Created attachment 327745 [details] System Monitor shows huge memory usage of Gnome Shell Appearance: when background settings changes fast and repeatedly - the more frequency, the greater and fastest memory usage can be observed. most noticeable when change wallpaper mode ("picture-options"), but changing "color-shading-type", and "picture-uri" values also works. Occurs: with proprietary and open-source drivers, with AMD/ATI and NVIDIA cards, on i386 and amd64 architecture, in X and Wayland session. I recreated this error in configurations: Ubuntu 14.04 amd64 gnome-shell 3.12.2 4.3.0 NVIDIA 355.11 Ubuntu 15.10 amd64 gnome-shell 3.16.4 4.4.0 NVIDIA 352.63 Fedora 24 i386 GNOME Shell 3.20.1 Gallium 0.4 on NVC4 Fedora 24 i386 GNOME Shell 3.20.1 Gallium 0.4 on ATI RV530 How reproduce the issue: 0. disable icons on desktop (gsettings set org.gnome.desktop.background show-desktop-icons false) I) how I found this bug: 1. open "gnome-tweak-tool" 2. go to "Desktop" -> "Background" (not "Lock Screen") 3. constantly and quickly change value in "Mode" combo box (by mouse scrolling, not click and choose from a list; to several seconds) II) how I recreated in other configurations: 1. set image as wallpaper 2. run this script to changing background settings repeatedly as fast as possible (warning: infinite loop, run in terminal, CTRL + C to cancel): #!/bin/bash declare -a arr=("wallpaper" "centered" "scaled" "stretched" "zoom" "spanned") while [ 1 ]; do for mode in "${arr[@]}"; do echo "$mode" gsettings set org.gnome.desktop.background picture-options "$mode" sleep 0.1 done done (Perhaps the problem is confirmed by another user in this commentary: https://bugzilla.gnome.org/show_bug.cgi?id=735705#c56)
Does the memory usage go down if you run "imports.system.gc()" in looking glass (<alt>f2 lg<enter>)?
(In reply to Florian Müllner from comment #1) > Does the memory usage go down if you run "imports.system.gc()" in looking > glass (<alt>f2 lg<enter>)? Memory usage is only increasing, and not decreasing, even after forcing garbage collector. When using proprietary graphics drivers, system starts to use swap space, everything is slowing down. Appear the message like "Failed to launch 'app' Failed to fork (Cannot allocate memory)", etc. Only restart shell (press ALT+F2, type r, and press Enter) can return to initial state (I will not make it on time, the all system is freeze). With using open-source drivers, freezing proceeds much faster, and then left only a hard reset computer.
(In reply to Florian Müllner from comment #1) > Does the memory usage go down if you run "imports.system.gc()" in looking > glass (<alt>f2 lg<enter>)? It does a significant amount here but not all the memory is recovered. If it was 312MB before the background change, it goes up to 321MB and the "imports.system.gc()" brings it down to 316MB.
Can garbage collection be done automatically?
Yes, same bug I have experienced and mentioned in the prior comment. gnome-shell slowly leaks memory as the background changes. The only way I can make the memory "go down" is by restarting gnome-shell with "r" through the run dialog or using `kill -1` to make it reload itself. Running imports.system.gc() does not have much, if any, effect on memory usage while gnome-shell is running. I should note, the only time I have personally seen this happen is when using proprietary video drivers (currently nvidia). When using an onboard intel graphics card with the open source drivers, I have no memory leaking problems to this extent. I can't use the nouveau driver to see if that helps memory either because it locks the GPU after 30 minutes or so forcing a reboot. Please let me know if there is any information I can contribute, I'd be more than happy to provide anything needed or desired just to help track this down.
Created attachment 329557 [details] [review] background: free MetaBackground explicitly when its MetaBackgroundActor is destroyed The problem happens when background mode or file is changed, because the memory which MetaBackground uses a lot of memory and not freed until garbage collection runs. The attached patch fixes this problem by freeing MetaBackground explicitly when its MetaBackgroundActor is destroyed. Please look at it, if it could be help. ps. I modified Damian's script for testing of changing background file. #!/bin/bash declare -a arr=("file:///usr/share/backgrounds/gnome/Blinds.jpg" "file:///usr/share/backgrounds/gnome/Bokeh_Tails.jpg" "file:///usr/share/backgrounds/gnome/Chmiri.jpg" "file:///usr/share/backgrounds/gnome/Dark_Ivy.jpg" "file:///usr/share/backgrounds/gnome/Fabric.jpg" "file:///usr/share/backgrounds/gnome/Flowerbed.jpg" "file:///usr/share/backgrounds/gnome/FootFall.png" "file:///usr/share/backgrounds/gnome/Godafoss_Iceland.jpg" "file:///usr/share/backgrounds/gnome/Mirror.jpg" "file:///usr/share/backgrounds/gnome/Road.jpg" "file:///usr/share/backgrounds/gnome/Sandstone.jpg" "file:///usr/share/backgrounds/gnome/Stones.jpg" "file:///usr/share/backgrounds/gnome/Terraform-green.jpg" "file:///usr/share/backgrounds/gnome/Waves.jpg" "file:///usr/share/backgrounds/gnome/Whispy_Tails.jpg" "file:///usr/share/backgrounds/gnome/adwaita-day.jpg" "file:///usr/share/backgrounds/gnome/adwaita-lock.jpg" "file:///usr/share/backgrounds/gnome/adwaita-morning.jpg" "file:///usr/share/backgrounds/gnome/adwaita-night.jpg") while [ 1 ]; do for f in "${arr[@]}"; do echo "$f" gsettings set org.gnome.desktop.background picture-uri "$f" sleep 0.1 done done
Review of attachment 329557 [details] [review]: LGTM, thanks!
Ups, this almost fell through the cracks. e0307bb..71c26cc gnome-3-20 -> gnome-3-20 b5dd4d1..e72d388 master -> master Attachment 329557 [details] pushed as e72d388 - background: free MetaBackground explicitly when its MetaBackgroundActor is destroyed
*** Bug 769927 has been marked as a duplicate of this bug. ***