Chartjs-ChartJs Memory Leak | Garbage Collection does not clean Chart Object or Arrays after render

0👍

In order for your charts to be garbage-collected, you must make sure that there are no remaining references to them.

Use chartInstance.destroy() to clean up Chart.js’s internal references to the chart object: documentation

When you call new Chart(...), you will have to store that reference somewhere (e.g. in an array) and call .destroy() on it when you’re done. Don’t forget to remove the reference from the array as well.

Leave a comment