fxingzhe Report post Posted January 20, 2014 in my project , I need to update my charts'data every 3 secords, so i fullfill it by calling setXmlData() every 3 secord ; however, I encountered such a problem that I found the memory usage was increasing in chrome, i check memory by chrome's task manager. what's wrong with it ? is there somthing wrong with setXmlData(), or how could i fullfill my task mentioned above. expecting your help. Share this post Link to post Share on other sites
Guest Sashibhusan Report post Posted January 21, 2014 Hi, Could you please let us know, how you are calling "setXMLData()" method in every 3 seconds? Are you using setInterval(), setTimeout() functions? If yes, please provide the screen shot of the memory usage from Chrome > Developer Tool > Timeline tab. For more information on "Memory Leak due to setInterval()", please visit the link: http://stackoverflow.com/questions/14034107/does-javascript-setinterval-method-cause-memory-leak Also, (if feasible) please provide a scaled down sample along with the statistical data of memory leak occurs at your end, to better look into your issue. Awaiting your response. Share this post Link to post Share on other sites
fxingzhe Report post Posted January 21, 2014 absolutely right , setInterval is used for triggering ajax events, setXmlData() method works in "success" callback function. screen shots collected by chrome developer tools is uploaded by attach file. schema code refers to fusioncharts function callback() { ........ FusionCharts("myChartID").setXMLData(xmlStr); ............ } setInterval(function(){ $ajax({ ......... success: callback(); }) },3000); i check the memory usage by chrome's task mamnager, and memory usage is a bit increasing, however , I can't judge what leads to such increase . by the way , thank you for your information on "Memory Leak due to setInterval()" , which inspires me a lot . expecting your guiding. Share this post Link to post Share on other sites
Guest Sashibhusan Report post Posted January 22, 2014 Hi, Thank you for your more inputs on this issue. As per the screen shot that you have provided, the time line graph is kind of saw tooth. This means, eventually after a regular interval of time, the GC is cleaning up the memory. Please note that on each anonymous function call, some memory is being allocated in the heap area and "setInterval()" will call the function again and again after a specified time interval, even if the previous function call not finish execution. So there could be a chance of not clearing the heap area for a period of time. So, to get the performance a bit better, you could use "setTimeOut()" to call the function that invokes itself indirectly through setTimeout() after it completes the work it's supposed to do. Please go through the link of Stackoverflow (provided in previous post), to have a clear idea on this approach. Hope this helps! Share this post Link to post Share on other sites
fxingzhe Report post Posted January 24, 2014 thanks for your help. Share this post Link to post Share on other sites
Guest Sashibhusan Report post Posted January 24, 2014 Share this post Link to post Share on other sites