Open qingguoYan opened 1 year ago
@qingguoYan It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗
I switched routes several times and ended up on the home route. After manually clicking on garbage collection, I generated a heap snapshot and saw that snapshot 7 generated more Geojson polygongeometry classes each time than snapshot 6. Why is that
这个问题应该确实存在,当通过 registerMap
注册了之后,会被始终存储在全局的 storage 中,调用单个实例对象的 dispose
方法并不会清空这些缓存的 map。可能增加一个 unregisterXXX 之类的 API 会比较有用,以允许开发者卸载相关注册。
@plainheart 这个其实还好,但是如果多次切换路由,每一次创建和销毁echart,内存都在缓慢的增长,我对比了堆快照,发现有一些类在echarts销毁后仍然在内存中,比如GeoJSONPolygonGeometry,这样会引起一个问题,假设用户永远不关闭浏览器,并一直使用页面,最终内存会超出,浏览器crash
还有一些游离的节点存在内存中,很明显包括canvas这样和echart相关的
Version
5.4.0
Link to Minimal Reproduction
https://codesandbox.io/s/condescending-dubinsky-wlcpwt?file=/src/routers/echarts/index.js
Steps to Reproduce
Current Behavior
echart register map,switch route to home, I think echarts should disapper from memory,but it is still in memory. and if I switch route some times and stop on the home route finally,Memory is growing slowly.
Expected Behavior
Echarts disappears from memory when I leave the ECHARTS route, and memory doesn't keep growing as I switch routes
Environment
Any additional comments?
No response