![Firefox Memory Leak Firefox Memory Leak](/uploads/1/1/9/4/119421068/306929326.png)
![Leak Leak](/uploads/1/1/9/4/119421068/476005101.jpg)
Restart Firefox. If you leave Firefox open for a longer period of time, it tends to use more system. I doubt that this problem can be repaired.The browsers I used, firefox,manthon,Avant browser, opera,chrome needless to say IE all have the Memory leaks. IEmanthonfirefoxavant browserchrome,chrome is the one has least memory leaks,Avant browser is the second. AVG 9 (unknown, but various reports of memory leaks in firefox with this) Kaspersky IS (mozilla virtual keyboard 3 module breaks garbage collector under XP, not verified for NT6+) Extensions / modules causing a memory issue is easy to isolate. When doing isolation tests i load a profile with a few hundred tabs worth of facebook.
ECharts is “[a] powerful, interactive charting and visualization library for browser”, an open-source js library developed by the team of Baidu. The interface of ECharts is very simple that just takes an object for the options, and it can create thousands of visualization combinations. It can handle large data rendering in canvas or svg, and there are many chart types pre-defined already. It also has a very detailed documentation (although sometimes the Chinese version has better explanation).
Don’t get me wrong of pointing out the issue of it and disliking it. I love using ECharts a lot. Here I am focusing only on why the memory leak of ECharts occurs. For how to find it, I highly recommend reading this article written by Kayce Basques from Google https://developers.google.com/web/tools/chrome-devtools/memory-problems/.
I occasionally check if there is any memory leak in my code, and today I found out that ECharts had memory leak even after I disposed the chart. Here is a link to the demo: https://demo.kelvinau.net/echarts-memory-leak/.
ECharts instance exists in memory
Clicking the first button “Dispose without setting to null” will call chart.dispose(), which is the official function to dispose the chart. Using Chrome Heap snapshot, I can see that ECharts instance still exists after disposed, so I take a look at the dispose function.
The function is not very long, and it seems to be doing all sorts of cleaning. The only thing that looks strange to me is the first few lines. It checks if the instance is disposed, and gives a warning for dev version, and simply just returns.
Clicking dispose button a few more times
The ECharts instance exists to check if it is disposed. I consider this as a feature. Setting a breakpoint there, you can take a look at this to see what is left in the instance.
Firefox Memory Leak Fix
I briefly took a look at it and already saw two DOM elements in the instance, and I believe there should be more.