Persistent DOM references retained by Web Worker message handlers across message cycles
0 reputation · 04 Apr 2024, 08:03 UTC
This question addresses the persistence of DOM node references within a long-running HTML5 Web Worker across repeated message cycles. The goal is to determine whether unattached DOM elements retained by message handlers accumulate in the browser's heap and affect worker termination behavior.
A key uncertainty involves how browser memory profilers distinguish between garbage-collected but still-referenced nodes and genuinely leaked objects, particularly when closures capture the worker's message port or document context. Additionally, the leak may not manifest during short test runs and could require sustained operation or high message volume to surface.
What observable markers in a heap snapshot indicate that DOM node references are preventing worker garbage collection? Does the presence of repeatedly attached event listeners in a worker's message handler consistently increase retained size across iterations, and under what conditions does the browser reclaim the worker's memory after message port closure?