Opened 8 years ago
Closed 8 years ago
#15850 closed defect (worksforme)
Memory Leak When Updating Graph
Reported by: | jlkABB | Owned by: | Eugene Lazutkin |
---|---|---|---|
Priority: | undecided | Milestone: | tbd |
Component: | Charting | Version: | 1.8.0 |
Keywords: | Cc: | cjolif, Patrick Ruzand | |
Blocked By: | Blocking: |
Description
When continuously updating a graph the memory footprint continues to grow until it consumes all available memory.
A barebones example:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Graph Example</title> <script type="text/javascript" src="./js/dojo/dojo/dojo.js"></script> <script type="text/javascript"> dojo.require("dojox.charting.Chart2D"); dojo.require("dojox.charting.axis2d.Default"); dojo.require("dojox.charting.plot2d.Lines"); var dojoGraphObject = null; var on = true; var handle = null; /* * Convert an array of single values into an object with x,y plus tooltip for use in the dojo graph */ function dojoCountData(inArray){ var tempArray = new Array(); for(i in inArray) tempArray.push({x:i,y:inArray[i]}); return tempArray; } function setupGraph(id){ dojoGraphObject = new dojox.charting.Chart2D(id); dojoGraphObject.addPlot("default", { //type of chart type: "Lines", //show markers at number points? markers: true, //show lines? lines: true, //fill in areas? areas: false, //offset position for label labelOffset: -40, //add shadows to lines shadows: { dx:2, dy:2, dw:2 } }); //add a plot area for datapoints to exist in this.dojoGraphObject.addPlot("Grid", {type: "Grid", hMajorLines: true, hMinorLines: false, vMajorLines: true, vMinorLines: false }); } function addAxis(){ dojoGraphObject.addAxis("x",{min: 0, max: 100}); dojoGraphObject.addAxis("y", {vertical:true, min: 0, max: 100}); } function randomValues(){ var tempArray = new Array(); for(var i =0;i<100;i++) tempArray.push(Math.floor(Math.random()*101)); return tempArray; } function load(){ setupGraph("divDojoGraph"); addAxis(); dojoGraphObject.addSeries("Test",dojoCountData(randomValues())); dojoGraphObject.render(); handle = setInterval(addPoints,250); } function addPoints(){ this.dojoGraphObject.updateSeries("Test",dojoCountData(randomValues())); this.dojoGraphObject.render(); } function runToggle(button){ on = !on; if(on){ button.value = "Turn Off"; addPoints(); handle = setInterval(addPoints,250);} else{ button.value = "Turn On"; clearInterval(handle);} } </script> </head> <body onload="load();"> <div id="divDojoGraph" style="float:left;width:100%"></div> <br/><input type="button" id="btnAdd" value="Radomize Points" onclick="addPoints();" /> <br/><input type="button" id="btnToggle" value="Turn Off" onclick="runToggle(this);" /> </body> </html>
Change History (4)
comment:1 Changed 8 years ago by
Cc: | cjolif Patrick Ruzand added |
---|
comment:2 Changed 8 years ago by
Personally if I'm running the provided sample on Firefox 10 ESR on Windows 7, with Dojo 1.8 (final) and without the patch I don't notice a memory increase after 1 hour (looking at Task Manager). Are you running a different browser version, Dojo version (some other memory leaks were fixed between 1.7.2 and 1.8 for example) or OS version? How long do you wait?
comment:3 Changed 8 years ago by
Thank you both for the heads up. I was using 1.7.2 but now having swapped to 1.8 there is no longer an issue. Again, I thank you very much!
comment:4 Changed 8 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
This one was actually not reproducible anymore. That said #14589 is still open as some (other) leaks still exist.
this sounds like its related to the most recent comments on #14589. could you try the latest patch on that ticket (http://bugs.dojotoolkit.org/attachment/ticket/14589/memory-leak-fixes.diff) and see if it helps? that patch fixes a very significant memory leak that was discovered moments before 1.8 was tagged. if you can confirm that the patch fixes your problems we can work towards having that patch incorporated as quickly as possible.