Line Chart has memory leak
See original GitHub issueI ran into the same problem as other users where the line chart’s memory was not being released after calling destroy(). I took the sample line chart code to illustrate this. Simply call LoopIt() and watch the memory usage increase.
<!doctype html>
<html> <head> <title>Line Chart</title> <script src="../Chart.js"></script> </head> <body> <div style="width:30%"> <div> <canvas id="canvas" height="450" width="600"></canvas> </div> </div><script>
var randomScalingFactor = function(){ return 5};
var lineChartData = {
labels : ["January","February","March","April","May","June","July"],
datasets : [
{
label: "My First dataset",
fillColor : "rgba(220,220,220,0.2)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(220,220,220,1)",
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
},
{
label: "My Second dataset",
fillColor : "rgba(151,187,205,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(151,187,205,1)",
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
}
]
}
function Reload(){
var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx).Line(lineChartData, {
responsive: true
});
}
function LoopIt(){
if(!window.myLine)
Reload();
for(var i = 0; i < 100; i++)
{
myLine.destroy();
Reload();
}
}
</script>
</body>
</html>
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Memory leak in Line Chart data · Issue #2772 - GitHub
When popping screen back or selecting another tab from the UITabBarController, there will be a memory leak that'll occur from the chart.
Read more >Line chart memory leak in a one page application - RGraph
Hello RGraph team, I actually using RGraph.line to show a curve in one of pages in a web app. And every thing is...
Read more >Memory leak in google line charts - Stack Overflow
In the code above I was trying to splice/pop out the data in the array, but seems like thats wont do anything. The...
Read more >Real-time line chart & memory leak issue | DevExpress Support
A memory leak occurred while using a real-time linear chart. The source code used the source code of the 17.2 demo center. The...
Read more >I have a question about memory leak - Highcharts
Hello, I'm implementing a real-time chart with highchart v7 , javascript and chrome (newest). My chart updates the data received from the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No I didn’t, works perfect now!
@Legends did you call
destroy()
on that chart?