HumbleSoftware / Flotr2

Graphs and Charts for Canvas in JavaScript.
http://www.humblesoftware.com/flotr2/
MIT License
2.45k stars 528 forks source link

give me an idea for memory leak. #246

Closed soaMan closed 8 years ago

soaMan commented 10 years ago

redraw a flotr2 charts when data polled from server

the polling worked every 30s , and updated chart

then occured memory increas too high

i attached my source example below

function drawchart(chartId, min, max, text) { $('canvas').remove(); var d1 = []; var options, container, o; container = document.getElementById(chartId); d1 = [{data : cpuArray, label:'Usage Rate', lines :{fill:true}}]; if (!firstDraw) { options = { xaxis : { mode : 'time', timeMode : 'local', labelsAngle : 0 }, selection : { mode : 'x' }, legend : { show: false }, yaxis : { min : min, max : max }, grid : { verticalLines : false, horizontalLines : true, tickColor : '#6C6B6C' }, mouse : { track : true, trackFormatter: function(obj) { return obj.series.label + '\t' + ' : ' + obj.y+text; }, relative : true }, HtmlText : true, title : chartId }; // Draw graph with default options, overwriting with passed options function drawGraph(opts) { // Clone the options, so the 'options' variable always keeps intact. // o = Flotr..extend(Flotr..clone(options), opts || {}); return Flotr.draw(container, d1, options); } } drawGraph(); }

LinusU commented 10 years ago

@soaMan please wrap your code with following syntax:

```javascript
<your code>