PDA

View Full Version : Memory leak with every reload of store data



g.dufour
17 Jun 2011, 7:39 AM
I have the following function that collects jsdon data.
I have a "refresh" task that calls this function every 10 seconds.
When the refresh is active, I see a memory leak with every refresh.
When I stop the refresh, the leak stops.
I tried to 'delete' the Store and create a new one, same problem.
I tried with a fixed reader --> same problem.

I loaded the page withIEJSLeakDetector and I can see that with every refresh a new function is created that returns the json information that was downloaded.
Not sure why this function is created and why it is not deleted.




function gdnet_getItems(hostid)
{
if (my_items) {
my_items.reload();
return;
}
my_items = new Ext.data.Store( {
reader: new Ext.data.JsonReader({
fields: [ "hosts","itemid","type","snmp_community","snmp_oid","snmp_port","hostid","description","key_","delay","history","trends",
"lastvalue","lastclock","prevvalue","status","value_type","trapper_hosts","units","multiplier","delta","prevorgvalue","snmpv3_securityname",
"snmpv3_securitylevel","snmpv3_authpassphrase","snmpv3_privpassphrase","formula","error","lastlogsize","logtimefmt",
"templateid","valuemapid","delay_flex","params","ipmi_sensor","data_type","authtype","username","password","publickey",
"privatekey","mtime"],
root: 'result'
}),
proxy: new Ext.data.HttpProxy({
url: zabbix_api_url,
jsonData: '{ "jsonrpc":"2.0","method":"item.get","params":{"output":"extend", "hostids": ["' + hostid + '"]},"auth":"' + zabbix_auth + '","id":2}'
}),
listeners: {
load: {
fn: function() {
gdnet_items.list.push({hostid: hostid, item_list: this});
}
}
},
autoLoad: true
});
}




Here is the function that gets created with every refresh


function anonymous() {
return {"jsonrpc":"2.0","result":[{"hosts":[{"hostid":"10052"}],"itemid":"22167","type":"1","snmp_community":"public","snmp_oid":"interfaces.ifTable.ifEntry.ifInOctets.1","snmp_port":"161","hostid":"10052","description":"test2","key_":"1.1.1.1.","delay":"30","history":"90","trends":"365","lastvalue":null,"lastclock":null,"prevvalue":null,"status":"0","value_type":"3","trapper_hosts":"localhost","units":"","multiplier":"0","delta":"0","prevorgvalue":null,"snmpv3_securityname":"","snmpv3_securitylevel":"0","snmpv3_authpassphrase":"","snmpv3_privpassphrase":"","formula":"0","error":"","lastlogsize":"0","logtimefmt":"","templateid":"0","valuemapid":"0","delay_flex":"","params":"","ipmi_sensor":"","data_type":"0","authtype":"0","username":"","password":"","publickey":"","privatekey":"","mtime":"0"},{"hosts":[{"hostid":"10052"}],"itemid":"22166","type":"4","snmp_community":"public","snmp_oid":"interfaces.ifTable.ifEntry.ifInOctets.1","snmp_port":"161","hostid":"10052","description":"test","key_":"1.1.1.1.1.1","delay":"30","history":"90","trends":"365","lastvalue":null,"lastclock":null,"prevvalue":null,"status":"0","value_type":"3","trapper_hosts":"localhost","units":"","multiplier":"0","delta":"0","prevorgvalue":null,"snmpv3_securityname":"","snmpv3_securitylevel":"0","snmpv3_authpassphrase":"","snmpv3_privpassphrase":"","formula":"0","error":"","lastlogsize":"0","logtimefmt":"","templateid":"0","valuemapid":"0","delay_flex":"","params":"","ipmi_sensor":"","data_type":"0","authtype":"0","username":"","password":"","publickey":"","privatekey":"","mtime":"0"},{"hosts":[{"hostid":"10052"}],"itemid":"22168","type":"1","snmp_community":"public","snmp_oid":"interfaces.ifTable.ifEntry.ifInOctets.1","snmp_port":"161","hostid":"10052","description":"test3","key_":"test3","delay":"30","history":"90","trends":"365","lastvalue":null,"lastclock":null,"prevvalue":null,"status":"0","value_type":"3","trapper_hosts":"localhost","units":"","multiplier":"0","delta":"0","prevorgvalue":null,"snmpv3_securityname":"","snmpv3_securitylevel":"0","snmpv3_authpassphrase":"","snmpv3_privpassphrase":"","formula":"0","error":"","lastlogsize":"0","logtimefmt":"","templateid":"0","valuemapid":"0","delay_flex":"","params":"","ipmi_sensor":"","data_type":"0","authtype":"0","username":"","password":"","publickey":"","privatekey":"","mtime":"0"},{"hosts":[{"hostid":"10052"}],"itemid":"22169","type":"1","snmp_community":"public","snmp_oid":"interfaces.ifTable.ifEntry.ifInOctets.1","snmp_port":"161","hostid":"10052","description":"test4","key_":"test4","delay":"30","history":"90","trends":"365","lastvalue":null,"lastclock":null,"prevvalue":null,"status":"0","value_type":"3","trapper_hosts":"localhost","units":"","multiplier":"0","delta":"0","prevorgvalue":null,"snmpv3_securityname":"","snmpv3_securitylevel":"0","snmpv3_authpassphrase":"","snmpv3_privpassphrase":"","formula":"0","error":"","lastlogsize":"0","logtimefmt":"","templateid":"0","valuemapid":"0","delay_flex":"","params":"","ipmi_sensor":"","data_type":"0","authtype":"0","username":"","password":"","publickey":"","privatekey":"","mtime":"0"},{"hosts":[{"hostid":"10052"}],"itemid":"22170","type":"1","snmp_community":"public","snmp_oid":"interfaces.ifTable.ifEntry.ifInOctets.1","snmp_port":"161","hostid":"10052","description":"test5","key_":"test5","delay":"30","history":"90","trends":"365","lastvalue":null,"lastclock":null,"prevvalue":null,"status":"0","value_type":"3","trapper_hosts":"localhost","units":"","multiplier":"0","delta":"0","prevorgvalue":null,"snmpv3_securityname":"","snmpv3_securitylevel":"0","snmpv3_authpassphrase":"","snmpv3_privpassphrase":"","formula":"0","error":"","lastlogsize":"0","logtimefmt":"","templateid":"0","valuemapid":"0","delay_flex":"","params":"","ipmi_sensor":"","data_type":"0","authtype":"0","username":"","password":"","publickey":"","privatekey":"","mtime":"0"}],"id":2}
}


In my simple test I lost 2k with every refresh but in the production application I lose 50Mb.

Any help would be appreciated.

Thanks.

Gilles.

skirtle
17 Jun 2011, 7:53 PM
ExtJS version? Are you using any adapters, or just ext-base?

g.dufour
17 Jun 2011, 10:36 PM
Version 3.3.0 with jquery 1.4.2-min.

skirtle
19 Jun 2011, 3:36 PM
From a quick search of the jQuery source I found this:


return window.JSON && window.JSON.parse ?
window.JSON.parse( data ) :
(new Function("return " + data))();

I'd guess that's what you're seeing. No idea why that would cause a leak.

sytel
1 Sep 2011, 1:43 AM
Please have a look at http://www.sencha.com/forum/showthread.php?145645-Possible-memory-leak-with-GridPanel-and-Store