Closed
Bug 385086
Opened 18 years ago
Closed 18 years ago
null XPCOM refs in content pref services to prevent leaks
Categories
(Toolkit :: Preferences, defect)
Toolkit
Preferences
Tracking
()
RESOLVED
FIXED
People
(Reporter: myk, Assigned: myk)
References
Details
Attachments
(3 files)
1.50 KB,
patch
|
sayrer
:
review+
|
Details | Diff | Splinter Review |
2.93 KB,
patch
|
sayrer
:
review+
|
Details | Diff | Splinter Review |
4.08 KB,
patch
|
sayrer
:
review+
|
Details | Diff | Splinter Review |
After the content pref service got checked in, Rlk on fxdbug-linux-tbox went from 2.99KB to 3.07KB and then to 3.16KB. It now fluctuates between the latter two numbers, whereas before it was fluctuating between the former two.
Per discussion on #developers, one issue is references to XPCOM components in the member variables of the two services defined by nsContentPrefService.js (the content pref service and the content URI grouper). Those need to be nulled when the services are destroyed on shutdown.
Assignee | ||
Comment 1•18 years ago
|
||
Here's a patch that nulls all those references on shutdown. The only one it doesn't null is the _interfaces array of interfaces. If those need to be nulled as well, then perhaps it'd be better simply to inline the interfaces in the QueryInterface method.
Updated•18 years ago
|
Attachment #268992 -
Flags: review?(sayrer) → review+
Assignee | ||
Comment 2•18 years ago
|
||
Fix checked in to trunk:
Checking in toolkit/components/contentprefs/src/nsContentPrefService.js;
/cvsroot/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js,v <-- nsContentPrefService.js
new revision: 1.2; previous revision: 1.1
done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Comment 3•18 years ago
|
||
If this patch didn't fix the leaks, then is there any reason we shouldn't back it out?
Assignee | ||
Comment 4•18 years ago
|
||
In yesterday's conversation on IRC, some folks (brendan?) seemed to think it valuable to preemptively null references to XPCOM components even when doing so doesn't provide an immediately obvious benefit.
And at one point I think someone (sayrer?) also suggested that it would be valuable to null database statements to prevent them from hanging onto the database connection.
Comment 5•18 years ago
|
||
Comment on attachment 268992 [details] [diff] [review]
patch v1: nulls XPCOM refs in content pref service
You might rather write:
for (var i in this)
this[i] = null;
I did favor this kind of code from an XPCOM-shutdown protocol, and argued (I'm a realist) that it's not superstitious given our current world of leaks.
But it would be nice to roll it up into a loop.
/be
Comment 6•18 years ago
|
||
I don't pretend to know enough about what is important here...
But as _observers and _genericObservers have the potential to still be referencing (large) singeleton objects that haven't had removeObserver() called on them, should they be cleared as well?
Assignee | ||
Comment 7•18 years ago
|
||
(In reply to comment #6)
> I don't pretend to know enough about what is important here...
> But as _observers and _genericObservers have the potential to still be
> referencing (large) singeleton objects that haven't had removeObserver() called
> on them, should they be cleared as well?
Yes, you're right, indeed they should. Reopening to attach a patch for that as well.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 8•18 years ago
|
||
Here's a followup patch that clears the observer data structures and also nulls XPCOM component references in the browser/base/content/ JS files that were added as part of the content prefs checkin.
This patch also modifies the comments describing the nulling to clarify that the nulling is preemptive/precautionary.
Attachment #269251 -
Flags: review?(sayrer)
Comment 9•18 years ago
|
||
Comment on attachment 269251 [details] [diff] [review]
followup v1: removes observers, also fixes browser/ files, clarifies comments
Still leaking with this patch?
Assignee | ||
Comment 10•18 years ago
|
||
(In reply to comment #9)
> (From update of attachment 269251 [details] [diff] [review])
> Still leaking with this patch?
Yeah, unfortunately this doesn't actually fix the leak, which is expected, since at the moment the only consumer of the content prefs service is the text zoom controller, and that properly removes itself as an observer on browser shutdown.
This fix is more to make sure we don't leak if other consumers (perhaps in extensions) don't properly remove themselves in the future.
Updated•18 years ago
|
Attachment #269251 -
Flags: review?(sayrer) → review+
Assignee | ||
Comment 11•18 years ago
|
||
Followup patch checked in:
Checking in toolkit/components/contentprefs/src/nsContentPrefService.js;
/cvsroot/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js,v <-- nsContentPrefService.js
new revision: 1.3; previous revision: 1.2
done
Checking in browser/base/content/browser-contentPrefSink.js;
/cvsroot/mozilla/browser/base/content/browser-contentPrefSink.js,v <-- browser-contentPrefSink.js
new revision: 1.2; previous revision: 1.1
done
Checking in browser/base/content/browser-textZoom.js;
/cvsroot/mozilla/browser/base/content/browser-textZoom.js,v <-- browser-textZoom.js
new revision: 1.2; previous revision: 1.1
done
Status: REOPENED → RESOLVED
Closed: 18 years ago → 18 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 12•18 years ago
|
||
Hrm, sorry about the churn, but somehow I missed Brendan's comment 5. Not sure why. I found the bugmail marked read in my Inbox, but I don't recall reading it.
I'll attach a followup patch that uses the approach he outlines.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 13•18 years ago
|
||
Here's a patch that implements Brendan's approach with the addition of a try-catch block to catch "setting a property that has only a getter" exceptions when the loop tries to null read-only properties.
Attachment #269276 -
Flags: review?(sayrer)
Comment 14•18 years ago
|
||
Comment on attachment 269276 [details] [diff] [review]
followup 2 v1: Brendan's suggestion
oh, that is nicer. what a tough reviewer I am ;)
Attachment #269276 -
Flags: review?(sayrer) → review+
Assignee | ||
Comment 15•18 years ago
|
||
Thanks Robert. Hopefully this is the last iteration for this bug. Fix checked in to trunk:
Checking in toolkit/components/contentprefs/src/nsContentPrefService.js;
/cvsroot/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js,v <-- nsContentPrefService.js
new revision: 1.4; previous revision: 1.3
done
Checking in browser/base/content/browser-contentPrefSink.js;
/cvsroot/mozilla/browser/base/content/browser-contentPrefSink.js,v <-- browser-contentPrefSink.js
new revision: 1.3; previous revision: 1.2
done
Checking in browser/base/content/browser-textZoom.js;
/cvsroot/mozilla/browser/base/content/browser-textZoom.js,v <-- browser-textZoom.js
new revision: 1.3; previous revision: 1.2
done
Status: REOPENED → RESOLVED
Closed: 18 years ago → 18 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•