Open
Bug 1912748
Opened 1 year ago
Updated 1 year ago
Garbage Collector skip a detached span element which has only WeakRef
Categories
(Core :: JavaScript: GC, defect, P5)
Tracking
()
UNCONFIRMED
People
(Reporter: gholk, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
|
1.71 KB,
text/html
|
Details |
First, I am not sure whether a WeakRef's target can not be reclaimed or a memory leak in js is a bug.
I am building a UI library for hobby, and face this bug in firefox.
I use WeakRef to make ui elements could be reclaim,
but I notice that with WeakRef they are still alive.
Please find the example code in the attachment.
Step:
- The attachment creates 3 object/element and make only WeakRef to them.
- When user click the button, it will show whether the WeakRef's target object is still alive.
- Do something to trigger the GC, like click button in about:memory
- The first span element is not reclaimed, though it was not referenced by anything, too
Condition to reproduce is a little complicate:
- They must be dom object, elements or text nodes.
- The WeakRef is created from the function argument and capture with a closure.
- The function is bind to a EventTarget (but not the window)
I write some details in the attachment's js comment.
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::JavaScript: GC' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Component: Untriaged → JavaScript: GC
Product: Firefox → Core
Comment 2•1 year ago
|
||
Steve, could looking into this GC bug and help triage it? Since it has a test case that could make this actionable.
Flags: needinfo?(sphink)
Updated•1 year ago
|
Severity: -- → S4
Priority: -- → P5
Updated•1 year ago
|
Blocks: GC.performance
You need to log in
before you can comment on or make changes to this bug.
Description
•