d3 / d3-selection

Transform the DOM by selecting elements and joining to data.

Home Page:https://d3js.org/d3-selection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suspect memory leak when update frequently in realtime

dragonsoft-cara opened this issue · comments

commented

Hi there,
I found memory leak when using exist().remove() and append() to dynamically update digram.
Could any one help to see if there's any wrong in my code or is this an issue with d3, I'm using version 3.x.

screen shot 2018-11-26 at 10 19 44

Here's the demo:
JSBin
Devtool friendly

The main code to update diagram:

    var letters = d3.select('svg').selectAll('text').data(vowelsAndNums, function(d) {
  		return d;
  	});

    letters.exit().remove();

    letters.attr('x', function(d,i) { return i*15; });

    letters.enter().append('text')
    	.text(function(d) { return d; })
    	.attr('x', function(d,i) { return i*15; })
    	.attr('y', 15);

I don’t support D3 3.x anymore, sorry. I’m aware of a memory leak with event listeners #189 (#186 (comment)), but that shouldn’t apply in this example since you’re not using selection.on.