Closed Bug 655227 Opened 13 years ago Closed 6 years ago

Timers using small intervals (100ms or less) are never garbage collected

Categories

(Core :: XPConnect, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INACTIVE

People

(Reporter: jwkbugzilla, Unassigned)

References

Details

(Keywords: memory-leak, Whiteboard: [MemShrink:P3])

Attachments

(1 file)

882 bytes, application/x-xpinstall
Details
Attached file Testcase extension
If somebody creates a TYPE_REPEATING_SLACK timer with a small interval (100 ms or less) and forgets to cancel it this timer and the corresponding observer will leak. This doesn't happen for timers with higher intervals, these are eventually garbage collected.

To reproduce install the attached extension and open chrome://testextension/content/test.html. This page creates a timer with interval 50ms printing a message to Error Console, it then immediately forgets about it. But the timer keeps printing to Error Console forever even though no references to that timer exist and it should have been garbage collected.

This is not a regression, I could reproduce in Firefox 3.5, 3.6, 4.0 and in the 20110505 mozilla-central nightly.
Interesting.  I wonder what's happening there; the timer should go away when its refcount goes to 1, so it sounds like by the time we manage to GC its wrapper (if ever) something else is holding a ref to it.

In any case, there has been talk of changing the timer API so that if the timer is armed that keeps it alive, period, and getting rid of the current weird GC-dependent behavior.
Component: General → XPConnect
QA Contact: general → xpconnect
My suspicion was that the timer and its wrapper cannot be collected in one go. So the wrapper is garbage collected, then the timer fires and another wrapper is created for the subject parameter of the observer. And that wrapper prevents the timer from being collected - until the wrapper is garbage collected again.

I simply discovered this condition in Adblock Plus and was wondering why the timer continued to run even though I verified that all references to it have been removed.
Hmm.  When the wrapper is collected I would expect it to call Release() on the timer which should immediately cancel the timer...
No longer blocks: mlk-fx5+
Whiteboard: [MemShrink:P3]
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: