Re: Leaks in nsSessionStore.js?
"L. David Baron" <[email protected]> Sat, 17 Nov 2007 16:33:53 -0800
| Newsgroups | gmane.comp.mozilla.performance |
|---|---|
| Message-ID | <[email protected]> |
On Sunday 2007-11-18 03:11 +0300, Nickolay Ponomarev wrote: > There's one case you shouldn't use weak reference from my experience: > when the observer is in a window (as opposed to a JS component). > Otherwise since there is a period of time when the window is closed, > but the GC hasn't happened, your observer may run in a closed window, > which usually leads to scary-sounding assertions and wrong behavior > (JS errors at least). More generally, you shouldn't use weak references if you depend on those weak references going away at some particular time when you think the object ought to be destroyed. That causes user-visible actions to depend on destructor timing, which, in a garbage collected system, can change arbitrarily. It can also cause even more serious problems if there are leaks. (Recall the bug where the global history database was written to disk in the history service's destructor. This meant if the history service was leaked, history wasn't saved.) -David -- L. David Baron http://dbaron.org/ Mozilla Corporation http://www.mozilla.com/