Results 1 to 2 of 2

Thread: [4.2.0.179] Memory Leak in Ext.chart.Chart

    This duplicates another forum thread, you can visit that thread here.
  1. #1
    Ext JS Premium Member
    Join Date
    Sep 2009
    Posts
    59

    Default [4.2.0.179] Memory Leak in Ext.chart.Chart

    REQUIRED INFORMATION
    Ext version tested:

    • Ext 4.2.0.179
    Browser:
    • Chrome 29.0.1547.76 m
    Description:
    • Memory leak in Ext.chart.Chart
    Steps to reproduce the problem:
    • Create a store and a chart.
    • Constantly load new data into the chart's store.
    The result that was expected:
    • No growth in memory
    The result that occurs instead:
    • Growth in memory until the page crashes.
    • The problem was the Ext.data.Store created in Ext.chart.axis.Numeric doConstrain() function never gets destroyed.
    Test Case:
    Code:
    Ext.define('WeatherPoint', {
      extend: 'Ext.data.Model',
      fields: ['temperature', 'date']
    });
                    
    var data = [];
                    
    for( var i = 0; i < 500; ++i ) {
      data.push( { temperature: Math.floor((Math.random()*100)+1), date: i } );
    }
                    
    var store = Ext.create('Ext.data.Store', {
      model: 'WeatherPoint',
      proxy: {
        type: 'memory',
        reader: {
          type: 'json',
          root: 'items'
        }
      },
      data: data
    });
                    
    Ext.create('Ext.chart.Chart', {
      axes: [
        {
          title: 'Temperature',
          type: 'Numeric',
          position: 'left',
          fields: ['temperature'],
          minimum: 0,
          maximum: 100
        },
        {
          title: 'Time',
          type: 'Numeric',
          position: 'bottom',
          fields: ['date']
        }
      ],
      series: [
        {
          type: 'line',
          xField: 'date',
          yField: 'temperature'
        }
      ],
      renderTo: Ext.getBody(),
      width: 800,
      height: 300,
      store: store
    });
                    
    var reloadData = function() {
      data = [];
      for( var i = 0; i < 500; ++i ) {
        data.push( { temperature: Math.floor((Math.random()*100)+1), date: i } );
      }
      store.loadData( data );
      Ext.defer( reloadData, 100 );
    };
                    
    Ext.defer( reloadData, 100 );
    Workaround:
    Add an override to destroy the unneeded store.
    Code:
        
    Ext.override( Ext.chart.Chart, {            
      setSubStore: function(subStore){
        //Destroy the previous subStore before replacing it.
        if( this.substore != null && this.substore != undefined ) {
          this.substore.removeAll();
          this.substore.getProxy().clearListeners();
          this.substore.destroy();
        }
        this.substore = subStore;
      }
    });
    Last edited by wsi; 3 Oct 2013 at 12:05 PM. Reason: Updated the workaround to also clearListeners

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

    Default

    Seems to be the same issue here:
    http://www.sencha.com/forum/showthread.php?268821

    Currently due to be fixed in 4.2.3.

Posting Permissions

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