dai Report post Posted February 24, 2012 (edited) I use the Ajax object in IE8 myChart, memory has not been released, and in CHROME and FIREFOX did not appear in this situation. The hope can help me to check. In addition, there are other solutions. </span> <%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <script src="../FusionChartsBroad/jquery-1.4.2.js" type="text/javascript"></script> <script language="JavaScript" src="../FusionChartsBroad/FusionCharts.js"></script> </head> <body> <div id="chartdiv" align="center"></div> </body> </html> <script type="text/javascript"> $(document).ready(function () { setInterval("aa()",10000); }); function test() { $.ajax({ type:"POST", url:"../FusionChartsBroad/Test_Error_Data.jsp", success: function(responseText){ var myChart = new FusionCharts("../FusionChartsBroad/AngularGauge.swf", "myChartId", "350", "200", "0", "0"); myChart.setDataXML(responseText); myChart.render("chartdiv"); myChart = null; delete myChart; CollectGarbage(); } }); } </script> Edited February 24, 2012 by dai Share this post Link to post Share on other sites
shamasis Report post Posted February 25, 2012 Hey, In your ajax success function, what does CollectGarbage() do? In any case, a better approach would be if you rewrite the success function as (I am assuming that you are using the latest FusionCharts.js - 3.2.2-SR2): function(responseText){ var myChart = window.myChart; if (myChart) { myChart.dispose && myChart.dispose(); delete window.myChart; myChart = null; } myChart = window.myChart = new FusionCharts("../FusionChartsBroad/AngularGauge.swf", "myChartId", "350", "200"); myChart.setXMLData(responseText); myChart.render("chartdiv"); myChart = null; } In essence, before creating a new FusionCHarts instance, check to see if an older one exists. If yes then call dispose() on it. The code snippet of mine can be made more elegant, but essentially the logic remains this way. Also, in case you are facing issues with memory release in JavaScript variants of the charts, then the upcoming release of FusionCharts (3.2.2.-SR3) should plug it up. PS: I also spotted that you are using deprecated setDataXML() Share this post Link to post Share on other sites
dai Report post Posted February 27, 2012 Your reply helped me solve the problem! Thank you very much for your help!... Share this post Link to post Share on other sites
Guest Sumedh Report post Posted February 28, 2012 Hi, Glad that, your issue is resolved. Happy FusionCharting ! Share this post Link to post Share on other sites
nhustak Report post Posted March 10, 2012 Hey, In your ajax success function, what does CollectGarbage() do? In any case, a better approach would be if you rewrite the success function as (I am assuming that you are using the latest FusionCharts.js - 3.2.2-SR2): function(responseText){ var myChart = window.myChart; if (myChart) { myChart.dispose && myChart.dispose(); delete window.myChart; myChart = null; } myChart = window.myChart = new FusionCharts("../FusionChartsBroad/AngularGauge.swf", "myChartId", "350", "200"); myChart.setXMLData(responseText); myChart.render("chartdiv"); myChart = null; } In essence, before creating a new FusionCHarts instance, check to see if an older one exists. If yes then call dispose() on it. The code snippet of mine can be made more elegant, but essentially the logic remains this way. Also, in case you are facing issues with memory release in JavaScript variants of the charts, then the upcoming release of FusionCharts (3.2.2.-SR3) should plug it up. PS: I also spotted that you are using deprecated setDataXML() If the chart size isn't changing, wouldn't it be faster to see if the chart has already been rendered and simply call setXMLData on the original chart? This is normally what we do - we have pages with 35 charts on them - I wouldn't want to take the time to dispose them all. So: if ( mychart) { myChart.setXMLData(responseText); } else{ myChart = window.myChart = new FusionCharts("../FusionChartsBroad/AngularGauge.swf", "myChartId", "350", "200"); myChart.setXMLData(responseText); myChart.render("chartdiv"); } Share this post Link to post Share on other sites
shamasis Report post Posted March 11, 2012 If the chart size isn't changing, wouldn't it be faster to see if the chart has already been rendered and simply call setXMLData on the original chart? This is normally what we do - we have pages with 35 charts on them - I wouldn't want to take the time to dispose them all. ... Yeah, if the use-case does not "require" recreating the chart, simply setting new data will work. PS: chart-type, chart-size and chart data can all be updated on a chart instance without creating a new FusionCharts every time. Share this post Link to post Share on other sites