PDA

View Full Version : a memory leak?



aj3423
30 May 2009, 11:30 PM
a grid and 2 buttons, when I click buttonA, the grid loads data like this:

dataA_1
dataA_2
dataA_3
....

when click buttonB, the grid remove all exist records and then loads:

dataB_1
dataB_2
dataB_3
....

each time I click button, the grid uses a JsonStore to load, I'm trying to save the loaded data to an array, when I click ButtonA again, the store should load from the array instead of send a load request.
my code is something like this:

var buffA = [];
buttonA.on('click', function() {
store.removeAll();
if(buffA.length > 0) { // already loaded
store.add(buffA);
} else {
store.load({
callback : function(recs) {
buffA = recs.slice(0);
}
});
}
}):

the problem is :
when I use store.add(buffA), each time I click the buttonA, the memory usage increases 2M and never goes down. how to prevent that?
THANKS.