镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Memory Leaks #7002

Open
Open

Description

@ergouser

One-line summary [问题简述]

Memory leak

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: Echarts 3.8.0 Full (downloaded today)
  • Browser version [浏览器类型和版本]:Chromium
    Version 62.0.3202.62 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (64-bit)
  • OS Version [操作系统类型和版本]:Linux hidden 4.4.0-97-generic 线图和饼图如何去除无数据的灰色symbol #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Chrome on Windows also seems to have the same problem.

Expected behaviour [期望结果]

All memory should be garbage collected.

Memory increase steadily and is never completely collected. Application eventually stops working.

As far as I can tell from the Chromium profiling tools, the variables that are not being collected are in the echarts source code, but my apologies if this is my Javascript that is causing the problem. Corrections and suggestions are appreciated for me and as a guide to others.

ECharts option [ECharts配置项]

Slightly modified version of:

https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-large

Full html file:

<html><head>
  <title>Generated for DIVXxChart3Big</title>
<script src="echarts.min.js"></script>
  </head>
 <body  
 <!--onload="DIVXxChart_init(document.getElementById('DIVXxChart3Big'));"--> >
<div id="DIVXxChart3Big" style="width: 800px; height: 650px;">         
</div>

<script type='application/javascript'>
var DIVXxChartBigVar = {
};


function DIVXxChartBig_init (doc) {
    DIVXxChartBigVar.myChart = echarts.init(doc);
    DIVXxChartBigVar.option = {
    title: {
        text: 'Big Data Set 5'
    },
    tooltip : {
        trigger: 'axis',
        showDelay : 0,
        axisPointer:{
            show: true,
            type : 'cross',
            lineStyle: {
                type : 'dashed',
                width : 1
            }
        },
        zlevel: 1
    },
    legend: {
        data:['sin','cos']
    },
    toolbox: {
        show : true,
        feature : {
            mark : {show: true},
            dataZoom : {show: true},
            dataView : {show: true, readOnly: false},
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    xAxis : [
        {
            type : 'value',
            scale:true
        }
    ],
    yAxis : [
        {
            type : 'value',
            scale:true
        }
    ],
    series : [
        {
            name:'sin',
            type:'scatter',
            large: true,
            symbolSize: 3,
            data: []
        },
        {
            name:'cos',
            type:'scatter',
            large: true,
            symbolSize: 2,
             data: []
         }
    ]
    };


        
             DIVXxChartBigVar.myChart.setOption(DIVXxChartBigVar.option);
             DIVXxChartBigVar.myChart.resize();
           };
        
function DIVXxChartBig_updateValues (incomingValue) {
                 var d = [];
                 var len = 10000;
                 var x = 0;
                 while (len--) {
                     x = (Math.random() * 10).toFixed(3) - 0;
                     d.push([
                         x,
                         //Math.random() * 10
                         (Math.sin(x) - x * (len % 2 ? 0.1 : -0.1) * Math.random()).toFixed(3) - 0
                     ]);
                 }
                  
                 var d1 = [];
                 len = 20000;
                 x = 0;
                 while (len--) {
                     x = (Math.random() * 10).toFixed(3) - 0;
                     d1.push([
                         x,
                         //Math.random() * 10
                         (Math.cos(x) - x * (len % 2 ? 0.1 : -0.1) * Math.random()).toFixed(3) - 0
                     ]);
                 }
                      DIVXxChartBigVar.myChart.setOption({
                         series: [{
                             data: d
                         },{
                             data: d1
                             }]
                     });
                     d1 = null;
                     d = null;
           };
 DIVXxChartBig_init(document.getElementById('DIVXxChart3Big'));
setInterval(function (){
DIVXxChartBig_updateValues(Math.random()*100)
},500);
</script>
</body></html>

Other comments [其他信息]

I think that this code also leaks, but the rate is much lower so I'm not a certain as of the one above.

<html><head>
  <title>Generated for DIVXxChart3</title>
<script src="echarts.min.js"></script>
  </head>
 <body  
 <!--onload="DIVXxChart_init(document.getElementById('DIVXxChart3'));"--> >
<div id="DIVXxChart3" style="width: 800px; height: 650px;">         
</div>

<script type='application/javascript'>
var DIVXxChartVar = {
};
           
function DIVXxChart_init (doc){
             DIVXxChartVar.myChart = echarts.init(doc);
             DIVXxChartVar.option = {
	          title: { text: 'EChart3' },
	          tooltip: { },
	          legend: { data: [ 'Sales' ] },
	          xAxis: { data: [ 'shirt', 'cardign', 'chiffon shirt', 'pants', 'heels', 'socks' ] },
	          yAxis: { },
	          series: [{
	            name: 'Sales',
	            type: 'bar',
	            data: [23, 20, 36, 10, 10, 20]
	          }]
             };
        
              DIVXxChartVar.myChart.setOption(DIVXxChartVar.option);
             DIVXxChartVar.myChart.resize();
           };
        
function DIVXxChart_updateValues(incomingValue) {
               var data0 = DIVXxChartVar.option.series[0].data;
              data0[0] = incomingValue +5;          
              DIVXxChartVar.myChart.setOption(DIVXxChartVar.option);
              data0 = null;
           };


 DIVXxChart_init(document.getElementById('DIVXxChart3'));
setInterval(function (){<html><head>
  <title>Generated for DIVXxChart3</title>
<script src="echarts.min.js"></script>
  </head>
 <body  
 <!--onload="DIVXxChart_init(document.getElementById('DIVXxChart3'));"--> >
<div id="DIVXxChart3" style="width: 800px; height: 650px;">         
</div>

<script type='application/javascript'>
var DIVXxChartVar = {
};
           
function DIVXxChart_init (doc){
             DIVXxChartVar.myChart = echarts.init(doc);
             DIVXxChartVar.option = {
	          title: { text: 'EChart3' },
	          tooltip: { },
	          legend: { data: [ 'Sales' ] },
	          xAxis: { data: [ 'shirt', 'cardign', 'chiffon shirt', 'pants', 'heels', 'socks' ] },
	          yAxis: { },
	          series: [{
	            name: 'Sales',
	            type: 'bar',
	            data: [23, 20, 36, 10, 10, 20]
	          }]
             };
        
              DIVXxChartVar.myChart.setOption(DIVXxChartVar.option);
             DIVXxChartVar.myChart.resize();
           };
        
function DIVXxChart_updateValues(incomingValue) {
               var data0 = DIVXxChartVar.option.series[0].data;
              data0[0] = incomingValue +5;          
              DIVXxChartVar.myChart.setOption(DIVXxChartVar.option);
              data0 = null;
           };


 DIVXxChart_init(document.getElementById('DIVXxChart3'));
setInterval(function (){
DIVXxChart_updateValues(Math.random()*100)
},500);
</script>
</body></html>
DIVXxChart_updateValues(Math.random()*100)
},500);
</script>
</body></html>

Activity

  1. ergouser commented on Nov 13, 2017

    @ergouser
    Author

    Issue still exists in version 3.8.4

  2. added
    pendingWe are not sure about whether this is a bug/new feature.
    on Dec 7, 2017
  3. yeongren commented on Jan 10, 2018

    @yeongren

    I am facing the same issue as well.

    Also, I realised that the dynamic charting tutorial having memory leak as well.

    https://ecomfe.github.io/echarts-examples/public/editor.html?c=doc-example/tutorial-dynamic-data

    https://ecomfe.github.io/echarts-doc/public/en/tutorial.html#Loading%20and%20Updating%20of%20Asynchronous%20Data

    @ergouser Did you manage to resolve the issue?

  4. sorenhoyer commented on Mar 7, 2018

    @sorenhoyer

    +1 using this for real time line chat with thousands of datapoints. Memory steadily increases over time.

  5. yeongren commented on Mar 13, 2018

    @yeongren

    @sorenhoyer Did you manage to solve the issue?

  6. luissmg commented on Mar 15, 2018

    @luissmg

    +1 I don't have that much data but I am using multiple charts on the same page and after a while it gets just impossible to use it.

  7. ergouser commented on Mar 15, 2018

    @ergouser
    Author

    @pissang Do we have an update? Has anything been fixed in the latest version (4.0.4)? Thanks.

  8. luissmg commented on Mar 15, 2018

    @luissmg

    @ergouser I don't think so because I have the latest release!

  9. sorenhoyer commented on Apr 4, 2018

    @sorenhoyer

    @komorebi-san unfortunately no, but creating your own charts with d3+html5 canvas is not that hard, and really pays off. That's what I ended up doing.

  10. yeongren commented on Apr 20, 2018

    @yeongren

    @sorenhoyer I guess you are right.

    I am surprised that this memory leak issue isn't an important one for them. ¯_(ツ)_/¯

  11. abkhalid commented on Aug 29, 2019

    @abkhalid

    @sorenhoyer I guess you are right.

    I am surprised that this memory leak issue isn't an important one for them. ¯_(ツ)_/¯

    Do you know if there is some way where we can register our request to get this prioritized

  12. abkhalid commented on Aug 29, 2019

    @abkhalid

    @komorebi-san unfortunately no, but creating your own charts with d3+html5 canvas is not that hard, and really pays off. That's what I ended up doing.

    Hi, would you be willing to share your library with the group?

  13. added this to the TBD milestone on Jan 8, 2020
  14. deleted a comment from echarts-bot on Jan 8, 2020
  15. ergouser commented on Jan 8, 2020

    @ergouser
    Author

    @komorebi-san @abkhalid @luissmg @sorenhoyer I've been running the attached example overnight without seeing any noticeable increase in memory usage. If you have examples that were previously showing an issue please retest against the latest (4.6) release and report any issues.

  16. ergouser commented on Jan 8, 2020

    @ergouser
    Author

    I think that this example still has a memory leak with 4.6. While the rate is much (much) smaller than earlier versions it still means that the application will crash, possibly after a week rather than a few minutes, but that's still not acceptable in a 24/7/365 production environment.

    I'm not completely sure that there is a leak. After running for about 20 hours the trend of the memory footprint for the tab running the chart code in Chromium is generally upwards. It started with a footprint oscillating around 100k and is now oscillating around about 200k. I didn't initially take note of the GPU memory usage, but that also seems to be trending upwards.

    While the snapshots seem to show a small (1.5MB) increase I can't definitively assign this to the application - I just started running the chart in an existing browser instance so it's possible JavaScript on other pages is contributing to this. I think that Chromium uses only one JS engine instance, but I'm not sure - I'm not an expert there. I'm also not enough of a JavaScript expert to confidently interpret the contents of the snapshot.

    There's definitely been some good progress, but given the critical nature of memory leaks I would appreciate is someone else could replicate and determine whether there is still a slow leak.

    I cannot detect any issues with the application in #10130 but that's a much smaller, less demanding application - it would take longer to demonstrate a problem.

  17. trannamquan commented on Jun 22, 2020

    @trannamquan

    This happens when the chart uses GL, also. It seems that charts using Gl cannot dispose properly. Can I know some ways to solve this memory leak problem?

  18. luissmg commented on Jun 28, 2020

    @luissmg

    Hey! Sorry for the late reply, I not in the project that used the lib, can't give you any insights on this :(

  19. aurelien-boubennec commented on Jan 13, 2023

    @aurelien-boubennec

    2 years later and I'm experiencing the same issue.

  20. retrievaaaa commented on Feb 6, 2023

    @retrievaaaa

    Also having this problem, after a few hours our site uses almost 800mb RAM which is obviously too much.

  21. 0xAskar commented on Mar 9, 2023

    @0xAskar

    I am having this problem as well, does anyone have a solution? Is there a cleanup method that needs to be enabled?

  22. linxiaowu66 commented on Apr 11, 2024

    @linxiaowu66

    so terrible! This issue hang up until today ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions