markmarkoh / datamaps

Customizable SVG map visualizations for the web in a single Javascript file using D3.js
http://datamaps.github.io
MIT License
3.78k stars 1.01k forks source link

World map bubbles leak memory #310

Open sumeetkpatel opened 8 years ago

sumeetkpatel commented 8 years ago

I am using the world map to plot some data in a live fashion where the bubbles update frequently and am noticing awsnap's from that page fairly frequently, upon investigation it seems every time a call is made to map.bubbles() with a new set of 'bubbles' to plot, it works but the old d3 svg nodes still remain and seem to use a fair amount of memory eventually causing the tab to be aborted (chrome).

I was able to limit the issue by removing all d3 circle nodes before adding new bubbles.

ie. d3.selectAll("circle").remove(); before map.bubbles()

You can see a basic example here: Leaking example Not Leaking example

The chrome task manager can be used to observe the leak.

dalpo commented 8 years ago

I encountered a similar memory leak issue. I'm not using the bubbles feature but I'm loading many times a wordmap via ajax (using Turbolinks).

I didn't find any way to free the allocated memory by the worldmap js library and this will cause the browser crash.