Looking at your code, I can kinda reproduce the memory usage. I had to go to extremes though and essentially do this:
while(true)
{
$('.flot').empty();
$.plot(".flot", [JSON.parse(data)] );
}
This caused thousands upon thousands of redraws and chewed up memory.
Emptying the div and re-initing the chart is not the proper way to redraw, however. You should be using a combination of setData
, setupGrid
and draw
. Doing this:
var splot = null;
while(true)
{
if (splot == null)
{
splot = $.plot(".flot", [JSON.parse(data)] );
}
else
{
splot.setData([JSON.parse(data)]);
splot.draw();
}
}
My memory usage was flat.
Also, your sample code doesn't show how you are using emberJS. I'm not very familiar with it, but I'd check very carefully that in it's data-binding glory it's not forcing the chart to redraw too frequently.