PDA

View Full Version : [OPEN-1099] Tiny memory increase in Ext.lib.Ajax, so tiny...



cyrilluce
2 Jul 2010, 1:59 AM
Ext version tested:


Ext 3.1.0



Adapter used:


ext



css used:


only default ext-all.css





Browser versions tested against:


sIEve (IE7)



Operating System:


WinXP Pro



Description:


Every ajax request will make about 0.13K memory increase in my sIEve.
Because Ext.lib.Ajax.poll & timeout object will add one property for every request.
After request complete, the property will set to null, not delete.
(delete is not enough with IE, because IE Object leaks)
This also cost some memory, though it's so tiny.
But if one request per second, and keep whole day, it will be 86400 * 2 property, about 10M



Test Case:



setInterval(function(){
Ext.lib.Ajax.request("GET","/test.json",Ext.emptyFn,{},{});
}, 10);
Possible fix:


// because "IE Object leaks", haven't directly use "delete"
function clean(obj) {
var o = {}, n,
for (n in obj) {
if (obj.hasOwnProperty(n)) {
v = obj[n];
if (v !== null) {
o[n] = v;
}
}
}
return o;
}
Ext.deepCleanThreadId = setInterval(function(){
Ext.lib.Ajax.poll = clean(Ext.lib.Ajax.poll);
Ext.lib.Ajax.timeout = clean(Ext.lib.Ajax.timeout);
}, 30000);

Stju
2 Jul 2010, 12:23 PM
Nice catch!

meroy
6 Jul 2010, 2:05 PM
Very nice. Small suggestion for readers: append "v;" to the variable declaration line.



var o = {}, n, v;