After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 738256 - Memory leak fixes
Memory leak fixes
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2014-10-09 18:33 UTC by Owen Taylor
Modified: 2015-11-23 23:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
AuthPrompt: properly remove user widgets (1.01 KB, patch)
2014-10-09 18:33 UTC, Owen Taylor
committed Details | Review
gdm: disconnect signals (11.19 KB, patch)
2014-10-09 18:33 UTC, Owen Taylor
committed Details | Review
gdm: fix missing parentheses (1.05 KB, patch)
2014-10-09 18:34 UTC, Owen Taylor
committed Details | Review
messageTray: add some missing signal disconnections (1.90 KB, patch)
2014-10-09 18:34 UTC, Owen Taylor
committed Details | Review

Description Owen Taylor 2014-10-09 18:33:49 UTC
Some memory leak fixes related to the lock screen dialog.
Comment 1 Owen Taylor 2014-10-09 18:33:52 UTC
Created attachment 288159 [details] [review]
AuthPrompt: properly remove user widgets

When replacing a user widget, we need to destroy the child, not just
unparent it, or it will leak.
Comment 2 Owen Taylor 2014-10-09 18:33:58 UTC
Created attachment 288160 [details] [review]
gdm: disconnect signals

Many signal connections on global objects and on non-widgets were not
disconnected when the unlock screen was destroyed, causing leaks.
Comment 3 Owen Taylor 2014-10-09 18:34:02 UTC
Created attachment 288161 [details] [review]
gdm: fix missing parentheses

Incorrect parentheses meant that if the ShellUserVerifier was destroyed before
the call to fprintManager.GetDefaultDeviceRemote(), the reply would result in
an error.
Comment 4 Owen Taylor 2014-10-09 18:34:08 UTC
Created attachment 288162 [details] [review]
messageTray: add some missing signal disconnections

Disconnect some signal connections that weren't disconnected on actor destroy
(not the result of comprehensive review.)
Comment 5 Ray Strode [halfline] 2014-10-09 19:18:53 UTC
Review of attachment 288159 [details] [review]:

so this confused me at first and owen and I chatted on irc about it. The issue here is the UserWidget class takes a couple of signal connections on a long lived object (ActUser object).  These signal connections don't get released until the UserWidget is destroyed.  The UserWidget isn't destroyed until widget actor is destroyed.  The actor can't be destroyed merely by being removed from the container because the user widget references the actor.
Comment 6 Ray Strode [halfline] 2014-10-09 19:39:15 UTC
Review of attachment 288160 [details] [review]:

thanks for the effort on this. clearly this was a ton of work.

::: js/gdm/authPrompt.js
@@ +138,1 @@
         this._userVerifier.disconnectAll();

don't need this disconnectAll anymore right?

::: js/gdm/loginDialog.js
@@ +936,3 @@
         }
 
+        this._userManagerAddedId = this._userManager.connect('user-added',

userAddedId might be clearer (and likewise for user-removed)

::: js/gdm/util.js
@@ +144,3 @@
 
+        this._smartcardInsertedId = this._smartcardManager.connect('smartcard-inserted',
+                                                                 Lang.bind(this, this._checkForSmartcard));

whitespace issue
Comment 7 Ray Strode [halfline] 2014-10-09 19:40:41 UTC
Review of attachment 288161 [details] [review]:

::: js/gdm/util.js
@@ +304,3 @@
                     this._haveFingerprintReader = true;
                     this._updateDefaultService();
+                }

ugh
Comment 8 Ray Strode [halfline] 2014-10-09 19:44:45 UTC
Comment on attachment 288162 [details] [review]
messageTray: add some missing signal disconnections

++
Comment 9 Jasper St. Pierre (not reading bugmail) 2014-10-09 19:46:00 UTC
Review of attachment 288161 [details] [review]:

(nit: these are braces, not parens)
Comment 10 Owen Taylor 2014-10-13 15:15:00 UTC
(In reply to comment #6)
> Review of attachment 288160 [details] [review]:
> 
> thanks for the effort on this. clearly this was a ton of work.
> 
> ::: js/gdm/authPrompt.js
> @@ +138,1 @@
>          this._userVerifier.disconnectAll();
> 
> don't need this disconnectAll anymore right?

Hmmm - so what you are saying is that if we properly disconnect from all global objects, remove timeouts, handle cancellation for all asynchronous calls, then we might still be connected to signals, but they will never be emitted, and we can just let the JS GC clean everything up. I agree, and checking, it does look like everything gets cleaned up on the ShellUserVerifier side - that was the point of my patch.

So it comes down to what is good style:

 Pro for disconnecting: if there are leaks, reduces the scope of the leak. Putting the disconnectAll() inside the destroy() method would be consistent with object.destroy() and widget.destroy() [though it's unobservable whether a signal is removed or just will never be emitted again]

 Con for disconnecting: disconnecting the signals on the JS side was the wrong way to handle left-over connections and turned noticeable backtraces to hard-to-detect leaks.
Comment 11 Owen Taylor 2014-10-13 15:52:40 UTC
Pushed all patches (changing "parentheses to braces" in the commit message :-) ... 
I went ahead and removed the disconnectedAll (and retested for memory leaks), since my
reasoning that the disconnectAll papered over the problems that were leading to the
memory leaks was convincing to me.

Attachment 288159 [details] pushed as d8d046f - AuthPrompt: properly remove user widgets
Attachment 288160 [details] pushed as 8d3ff56 - gdm: disconnect signals
Attachment 288162 [details] pushed as ffdb85e - messageTray: add some missing signal disconnections
Comment 12 Michael Catanzaro 2015-11-23 23:50:02 UTC
I fixed a small regression from this in e1e08f0a684281ba4df35d9ce5bc92f0510fd188