gnome-shell 42 leaks tens of megabytes with every screenshot

Bug #1973638 reported by Sugihwaras
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
GNOME Shell
Fix Released
Unknown
gjs (Ubuntu)
Fix Released
High
Jeremy Bícha
Jammy
Fix Released
High
Jeremy Bícha
gnome-shell (Ubuntu)
Fix Released
High
Unassigned
Jammy
Fix Released
High
Unassigned

Bug Description

[Impact]

gnome-shell's memory usage grows by tens of megabytes with every screenshot. A few screenshots make it 100MB larger and a few dozen screenshots make it 1GB larger.

[Test Plan for GNOME Shell Fix]

TODO

[Test Plan for GJS Fix]

1. Log into gnome-shell.

2. Measure its real memory usage:

   grep RSS /proc/`pidof gnome-shell`/status

3. Take 20 full screen screenshots by pressing PrtScn each time. No need to save them anywhere.

4. Measure the memory usage again.

Expected: Memory usage grows a little but growth does not exceed a few hundred megabytes. It should level off after a while and sometimes even shrink due to garbage collection.

Observed: Memory usage grows without bounds, easily exceeding 1GB after about 20 screenshots (depending on screen resolution). It never shrinks significantly.

[Where problems could occur]

Since the fix affects GJS, problems could occur in any part of gnome-shell.

[Other Info]

This leak requires multiple fixes to minimize the memory usage. For the moment we are only aiming to fix the main GJS portion of the bug that allows memory usage to exceed 1GB.

Revision history for this message
Sugihwaras (sugihwaras12) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote (last edit ):

The screenshot in comment #1 shows gnome-shell is only 168MB resident. So no leak there.

Please run:

  ps auxw > psoutput.txt
  free -h > free.txt
  lspci -k > lspci.txt
  journalctl -b0 > journal.txt

and attach the resulting text files here.

I suspect there is no leak here and we should instead investigate "system very laggy".

tags: added: gnome-shell-leak jammy
tags: removed: gnome-shell-leak
summary: - gnome-shell memory leak after did 100+ screenshot
+ System very laggy
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Re: System very laggy

Thank you for taking the time to report this bug and helping to make Ubuntu better. Please execute the following command only once, as it will automatically gather debugging information, in a terminal:

  apport-collect 1973638

When reporting bugs in the future please use apport by using 'ubuntu-bug' and the name of the package affected. You can learn more about this functionality at https://wiki.ubuntu.com/ReportingBugs.

affects: gnome-shell (Ubuntu) → ubuntu
Changed in ubuntu:
status: New → Incomplete
Revision history for this message
Sugihwaras (sugihwaras12) wrote :

my system laggy because gnome-shell used a lot swap 2000MB+ after 100+ screenshot (see htop res+swap). its not a normal.

i am sorry cant include this information because it past event.

  ps auxw > psoutput.txt
  free -h > free.txt

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I can't find a definition for what htop calls 'SWAP'. It might just be virtual memory usage since a few gigabytes is the normal amount of virtual memory usage by gnome-shell. If however htop defines 'SWAP' as actual swap file usage then yes there might be a leak in gnome-shell. But the fact that its RES size (presumably RSS or real RAM usage) is only 168M out of around 3750M of physical memory suggests something *other* than gnome-shell is using up all the RAM.

Next time the problem happens please run:

  ps auxw > psoutput.txt
  free -h > free.txt

and attach the resulting text files here.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Although reviewing the memory usage of gnome-shell after screenshots I can confirm there does seem to be a large memory leak of some sort there.

affects: ubuntu → gnome-shell (Ubuntu)
Changed in gnome-shell (Ubuntu):
status: Incomplete → Confirmed
summary: - System very laggy
+ gnome-shell leaks tens of megabytes with every screenshot
summary: - gnome-shell leaks tens of megabytes with every screenshot
+ gnome-shell 42 leaks tens of megabytes with every screenshot
tags: added: gnome-shell-leak
Changed in gnome-shell (Ubuntu):
importance: Undecided → High
status: Confirmed → Triaged
Revision history for this message
Sugihwaras (sugihwaras12) wrote : Dependencies.txt

apport information

tags: added: apport-collected third-party-packages
description: updated
Revision history for this message
Sugihwaras (sugihwaras12) wrote : GsettingsChanges.txt

apport information

Revision history for this message
Sugihwaras (sugihwaras12) wrote : ProcCpuinfoMinimal.txt

apport information

Revision history for this message
Sugihwaras (sugihwaras12) wrote : ProcEnviron.txt

apport information

Revision history for this message
Sugihwaras (sugihwaras12) wrote : ShellJournal.txt

apport information

Revision history for this message
Sugihwaras (sugihwaras12) wrote : monitors.xml.txt

apport information

Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Changed in gjs (Ubuntu):
importance: Undecided → High
status: New → In Progress
tags: added: rls-jj-incoming
Changed in gnome-shell (Ubuntu):
status: Triaged → Invalid
Changed in gnome-shell (Ubuntu Jammy):
status: New → Invalid
Changed in gjs (Ubuntu Jammy):
status: New → Triaged
importance: Undecided → High
tags: removed: rls-jj-incoming
Changed in gjs (Ubuntu):
assignee: nobody → Jeremy Bicha (jbicha)
Changed in gjs (Ubuntu Jammy):
assignee: nobody → Jeremy Bicha (jbicha)
tags: added: dt-405
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

As mentioned in https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5501, we need a fix for gnome-shell too, but most of the issue is in gjs.

Changed in gnome-shell (Ubuntu):
status: Invalid → Triaged
Changed in gnome-shell (Ubuntu Jammy):
status: Invalid → Triaged
importance: Undecided → High
Changed in gnome-shell (Ubuntu):
assignee: nobody → Jeremy Bicha (jbicha)
Changed in gnome-shell (Ubuntu Jammy):
assignee: nobody → Jeremy Bicha (jbicha)
description: updated
description: updated
Jeremy Bícha (jbicha)
Changed in gnome-shell (Ubuntu):
status: Triaged → Fix Committed
status: Fix Committed → Triaged
Changed in gjs (Ubuntu):
status: In Progress → Fix Committed
Changed in gjs (Ubuntu Jammy):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gjs - 1.72.0-4

---------------
gjs (1.72.0-4) unstable; urgency=medium

  [ Simon McVittie ]
  * d/copyright: Replace CC0-1.0 text with a reference to common-licenses

  [ Jeremy Bicha ]
  * Cherry-pick patch to fix memory leak seen when taking screenshots
    (LP: #1973638)

 -- Jeremy Bicha <email address hidden> Wed, 29 Jun 2022 08:40:12 -0400

Changed in gjs (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Steve Langasek (vorlon) wrote : Please test proposed package

Hello Sugihwaras, or anyone else affected,

Accepted gjs into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/gjs/1.72.0-3~ubuntu22.04.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

tags: added: verification-needed verification-needed-jammy
Revision history for this message
Jeremy Bícha (jbicha) wrote :

Before installing the update:
$ grep RSS /proc/`pidof gnome-shell`/status
VmRSS: 323100 kB
after running the 20 screenshots
$ grep RSS /proc/`pidof gnome-shell`/status
VmRSS: 605112 kB

and the size didn't really go down.

After installing gjs 1.72.0-3~ubuntu22.04.2,

$ grep RSS /proc/`pidof gnome-shell`/status
VmRSS: 325388 kB

After the 20 screenshots
$ grep RSS /proc/`pidof gnome-shell`/status
VmRSS: 559232 kB

After waiting a few moments
$ grep RSS /proc/`pidof gnome-shell`/status
VmRSS: 340772 kB

That verifies this bug fix.

Changed in gnome-shell (Ubuntu):
status: Triaged → Fix Released
status: Fix Released → Triaged
assignee: Jeremy Bicha (jbicha) → nobody
Changed in gnome-shell (Ubuntu Jammy):
assignee: Jeremy Bicha (jbicha) → nobody
tags: added: verification-done verification-done-jammy
removed: verification-needed verification-needed-jammy
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gjs - 1.72.0-3~ubuntu22.04.2

---------------
gjs (1.72.0-3~ubuntu22.04.2) jammy; urgency=medium

  * Cherry-pick patch to fix memory leak seen when taking screenshots
    (LP: #1973638)

 -- Jeremy Bicha <email address hidden> Wed, 29 Jun 2022 08:44:53 -0400

Changed in gjs (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for gjs has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

It looks like the final fix required has now landed in gnome-shell 43:

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2449

Changed in gnome-shell (Ubuntu):
status: Triaged → Fix Committed
tags: added: fixed-in-43 fixed-upstream
tags: added: rjs-jj-incoming
tags: added: rls-jj-incoming
removed: rjs-jj-incoming
description: updated
description: updated
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Nevermind. The gnome-shell fix was reverted upstream because it is incorrect.

tags: removed: rls-jj-incoming
Changed in gnome-shell (Ubuntu):
status: Fix Committed → Triaged
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hopefully this is the final gnome-shell fix:
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2461

Changed in gnome-shell (Ubuntu):
status: Triaged → Fix Committed
tags: added: fixed-in-43.rc
removed: fixed-in-43
Changed in gnome-shell (Ubuntu Jammy):
status: Triaged → Fix Committed
tags: added: fixed-in-42.5
Changed in gnome-shell (Ubuntu):
status: Fix Committed → Fix Released
Changed in gnome-shell:
status: Unknown → Fix Released
Revision history for this message
Sugihwaras (sugihwaras12) wrote (last edit ):

i am sorry forget this part because distrohop to fedora & opensuse.

i make new issue at gitlab about this issue too https://gitlab.gnome.org/GNOME/gjs/-/issues/526.

this part fix leak on gnome-shell part but its still have issue undefined ram usage increase like fedora and opensuse.

Changed in gnome-shell (Ubuntu Jammy):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.