Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用echarts内存溢出的问题 #11776

Closed
littleflyfly0610 opened this issue Dec 4, 2019 · 6 comments
Closed

使用echarts内存溢出的问题 #11776

littleflyfly0610 opened this issue Dec 4, 2019 · 6 comments
Labels
bug en This issue is in English inactive Not active for some time or no response from the author. Will be closed soon. missing-demo The author should provide a demo. pending We are not sure about whether this is a bug/new feature. waiting-for: author

Comments

@littleflyfly0610
Copy link

Version

4.2.1

Steps to reproduce

在项目中每十秒都会创建不同数量的图表然后下次创建之前都会把之前的图表全部dispose销毁,但是还是会发生内存泄漏,内存一直上涨

What is expected?

解决内存溢出问题

What is actually happening?

在项目中每十秒都会创建不同数量的图表然后下次创建之前都会把之前的图表全部dispose销毁,但是还是会发生内存泄漏,内存一直上涨

@echarts-bot
Copy link

echarts-bot bot commented Dec 4, 2019

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical questions.

If you are interested in the project, you may also subscribe our mail list.

Have a nice day! 🍵

@echarts-bot echarts-bot bot added bug en This issue is in English pending We are not sure about whether this is a bug/new feature. waiting-for: community labels Dec 4, 2019
@yufeng04
Copy link
Contributor

yufeng04 commented Dec 4, 2019

Please provide a reproducible demo!

@littleflyfly0610
Copy link
Author

littleflyfly0610 commented Dec 4, 2019

<script> ........ ........ ........ export default { name:'BarChart', data () { return { colorList: ['#0898D9','#8A86F6','#588BFF','#F1546B','#3527C4','#7297F2','#94CEFD','#FF6838','#00CA92','#EBB7FF','#AECD70','#AD5794'], timerID:null, } }, computed: { chartId(){ let fontString = 'abcdefghigklmnopqrstuvwxyz'; return this.id + fontString.substring(this.rnd(0,fontString.length-1)); //获取随机id }, myChart(){ return echarts.init(document.getElementById(this.chartId)) }, legend(){ if(this.chartOption.legend && this.chartOption.legend.length>0){ return this.chartOption.legend; }else{ let legendArr = []; if(this.chartOption && this.chartOption.series){ if(Object.prototype.toString.call(this.chartOption.series) === '[object Object]'){ // Object if(this.chartOption.series.name)legendArr.push(this.chartOption.series.name); }else if(Object.prototype.toString.call(this.chartOption.series) === '[object Array]' && this.chartOption.series.length > 0){ // Array for(let item of this.chartOption.series){ if(item.name)legendArr.push(item.name); } } } return Array.from(new Set([...legendArr])); } }, colorOption(){ if(this.chartOption && this.chartOption.color){ return Array.from(new Set([...this.chartOption.color,...this.colorList])); }else{ return this.colorList; } } }, props: { id: { type: String, require: true, default: '' }, /** * 自定义配置项,会覆盖默认配置 * 配置内容同echarts官方配置项 * label标签默认从传入的dataY中得name中取值,如需更改或清空,可在此配置 * eg: legend:{ data: [] } */ chartOption: { type: Object, require: false, default: ()=>{ return {} } } }, watch:{ chartOption:{ handler(newVal, val){ this.$nextTick(()=>{ if(this.myChart){ this.myChart.setOption(newVal); }else{ this.myChart.setOption(val); } }) }, immediate: true, deep: true } }, mounted(){ this.$nextTick(()=>{ this.drawBar(); this.timerID=setTimeout(()=>{ this.resizeCanvas(); },0) }) }, methods: { drawBar(){ let basicOption = { title: { text: '', }, color: this.colorOption, tooltip : { trigger: 'axis', axisPointer : { // 坐标轴指示器,坐标轴触发有效 type : 'line' // 默认为直线,可选为:'line' | 'shadow' } }, grid: { left: '3%', right: '4%', bottom: '6%', containLabel: true }, legend: { data:this.legend, // bottom: 0, // left: 'center' }, textStyle: { fontFamily: 'Microsoft YaHei' }, barMaxWidth: 30, barMinHeight: 1, xAxis : [], yAxis : [], series : [] } this.myChart.setOption(mergeObject(b ```asicOption,this.chartOption)); }, resizeCanvas(){ this.myChart.resize(); }, // 随机数 rnd(n, m){ let random = Math.floor(Math.random()*(m-n+1)+n); return random; } }, activated (){ this.resizeCanvas(); // window.addEventListener('resize',this.resizeCanvas()); }, deactivated(){ window.removeEventListener('resize',this.resizeCanvas); }, beforeDestroy(){ clearTimeout(this.timerID) this.myChart.dispose(); } } </script> 大致这么个组件虽然每次都dispose了但是还是会内存溢出如果重复创建````

@yufeng04
Copy link
Contributor

yufeng04 commented Dec 4, 2019

Could you provide a simple demo here?

@cyxiaotian
Copy link

echarts绘制数据现在看肯定时存储内存泄露的,不知道楼主这个问题是否有解决? 我用socketio做数据动态加载绘制动态折线图时也存在这样的问题

@Ovilia Ovilia added the missing-demo The author should provide a demo. label Mar 9, 2020
@Ovilia Ovilia added the inactive Not active for some time or no response from the author. Will be closed soon. label May 8, 2020
@echarts-bot
Copy link

echarts-bot bot commented May 8, 2020

This issue is closed due to not being active. Please feel free to open it again (for the author) or create a new one and reference this (for others) if you have further questions.

@echarts-bot echarts-bot bot closed this as completed May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English inactive Not active for some time or no response from the author. Will be closed soon. missing-demo The author should provide a demo. pending We are not sure about whether this is a bug/new feature. waiting-for: author
Projects
None yet
Development

No branches or pull requests

4 participants