PDA

View Full Version : [DUP] [4.2.0.179] Memory Leak in Ext.chart.Chart



wsi
23 Sep 2013, 4:00 PM
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:


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.


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;
}
});

Gary Schlosberg
24 Sep 2013, 6:13 AM
Seems to be the same issue here:
http://www.sencha.com/forum/showthread.php?268821

Currently due to be fixed in 4.2.3.