Results 1 to 10 of 10

Thread: Memory leak with charts

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-15255 in 5.1.2.
  1. #1
    Sencha Premium Member
    Join Date
    Dec 2013
    Posts
    42

    Default Memory leak with charts

    Hi,

    I have a container that gets updated with charts. Each time the container is cleared and a new chart is added (the container is not only used for charts so the same one cannot be reused). I am noticing that the memory continually increases. I have created a fiddle that contains a chart and a button that will clear and add a new chart. On chrome I can see the memory continually increase in the task manager as the button is clicked (it is showing up as JavaScript live memory). Here is the fiddle:

    https://fiddle.sencha.com/#fiddle/at7

    Regards,
    Paul

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha Premium Member
    Join Date
    Dec 2013
    Posts
    42

    Default

    Do you have a suggestion for how to fix this as the memory usage very quickly becomes a problem in my app.

    Thanks,
    Paul

  4. #4
    Sencha User
    Join Date
    Sep 2011
    Posts
    574

    Default

    Have you tried to replace series and data only? Not the whole chart?

  5. #5
    Sencha Premium Member
    Join Date
    Dec 2013
    Posts
    42

    Default

    Thanks for the suggestion but my container will not always be showing a chart. It depends on the type of data being display (i.e. it could be text, image, chart, etc.). But, I did try just calling setSeries and setData and it still continues to increase in memory usage.

    I did notice that the destroy method of the series is not being called but I updated AbstractChart.js to do this and it still doesn't help. Something else is keeping a reference by the looks of things...

    Any help (or a fix!) would be appreciated,
    Paul

  6. #6
    Sencha User sksoft's Avatar
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    34

    Default

    Just noticed a strange thing, every time I press "Run Fiddle" button (without pressing Update button in the snippet) the memory is increased. Leaks in Sencha Fiddle itself?

  7. #7
    Sencha Premium Member
    Join Date
    Mar 2013
    Posts
    28

    Default

    I need a solution to this as I have built a self updating dashboard that needs to stop leaking memory.

  8. #8
    Sencha - Ext JS Dev Team vitalyx's Avatar
    Join Date
    Jul 2012
    Posts
    40

    Default

    This was fixed. Please check latest nightlies next week.

  9. #9
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,339

    Default

    Quote Originally Posted by vitalyx View Post
    This was fixed. Please check latest nightlies next week.

    I didn't see any changes in the nightly charting package last week. When can we see these changes?

  10. #10

    Default

    For those who still work with a version prior 5.1.2 please use the fix mentioned below. It helped me solving the memory issue with a chart whose datapoints visualize the rows currently selected in a grid. With each selection change the chart is recreated with a new store that is built based on the selected rows. I quickly figured out that when playing around with a grid containing thousands of records the memory consumption enormously grew until the browser crashed.

    The problem in former versions is that neither interactions, axes nor series are destroyed when destroying the chart component. Latter is responsible for releasing the underlying store required that it has been configured to be auto-destroyed (property autoDestroyed).


    Code:
    /**
     * Chart memory leak. Interactions, axes and series are not destroyed. Latter leads to not destroying the underlying store.
     * Fixed in 5.1.2
     * @see https://www.sencha.com/forum/showthread.php?292403
     */
    Ext.define('MyApp.bugfix.EXTJS-15255', {
        override: 'Ext.chart.AbstractChart',
        
        // @private remove gently.
        destroy: function () {
            var me = this,
                legend = me.getLegend(),
                axes = me.getAxes(),
                series = me.getSeries(),
                interactions = me.getInteractions(),
                i, ln;
    
    
            me.surfaceMap = null;
            me.setHighlightItem(null);
    
    
            for (i = 0, ln = interactions.length; i < ln; i++) {
                interactions[i].destroy();
            }
            for (i = 0, ln = axes.length; i < ln; i++) {
                axes[i].destroy();
            }
            for (i = 0, ln = series.length; i < ln; i++) {
                series[i].destroy();
            }
            
            if (legend) {
                legend.destroy();
                me.setLegend(null);
            }
            me.legendStore = null;
            me.setStore(null);
            me.cancelLayout();
    
    
            me.callParent(arguments);
        }
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •