zepto icon indicating copy to clipboard operation
zepto copied to clipboard

DOM event listeners leak with detached nodes

Open antelle opened this issue 8 years ago • 1 comments

I've noticed a leak of DOM nodes and attached listeners with zepto. Here's a simple case:

<div id="top"></div>
function doWork() {
    $('#top').html('<div title="test element" id="inner">testing</div>');
    $('#inner').click(cb);
    timeout = setTimeout(doWork, 1);
}
function cb() { console.log('callback'); }
doWork();

When capturing Timeline after running several minutes with Zepto I see the following: zepto Nodes are not collected by GC, references to them are somewhere inside Zepto, JS heap is increasing.

If I replace Zepto with jQuery: jquery With jQuery, listeners count is stable, nodes count is increasing during the capture but returns back to small amount after restrating the timeline, as expected, JS heap doesn't grow: this timeline was captured after several minutes, and you can compare the numbers with Zepto.

Zepto 1.1.6, jQuery 2.2.0, Chrome 48 (Mac OS X)

antelle avatar Feb 07 '16 10:02 antelle