javascript - Memory leak with DataTable and DataSource with polling -


i have datatable populated remote json datasource:

var datasource = new y.datasource.get({ source: url });  datasource.plug(y.plugin.datasourcejsonschema, {     schema: {         resultlistlocator: "results",         resultfields:  [ "field1", "field2" ]     } });  var table = new y.datatable({ columns = ["col1", "col2"] }  table.plug(y.plugin.datatabledatasource, { datasource: datasource });  table.render("#table");  table.datasource.load({ request: query }); 

i'm trying have data in table refreshed periodically. a forum poster recommended calling load periodically, i've tried , works hoping (data refreshes without displaying loading... message).

y.later(1000/*ms*/, table.datasource, table.datasource.load, { request: query }, true); 

however, i've noticed memory leak in chrome. table cells don't seem removed memory. chrome's heap profiler reporting lots of htmltablecellelement objects in detached dom tree.

is best method of refreshing data? if so, there way clear out old table cells?

alternatives

there datatable-polling module can periodic fetching of data. can't examples of how supposed used yui3 datatable though. however, examples yui2 show can following, appears work:

datasource.setinterval(1000,              {         request: query,         callback:              {                 success: function(e) { table.ondatareturninitializetable },                 failure: function() { y.log("polling failure", "error"); }             }     }); 

however, looks load doing under hood anyway:

load: function(config) {     config = config || {};     config.request = config.request || this.get("initialrequest");     config.callback = config.callback || {         success: y.bind(this.ondatareturninitializetable, this),         failure: y.bind(this.ondatareturninitializetable, this),         argument: this.get("host").get("state") //todo     };      var ds = (config.datasource || this.get("datasource"));     if(ds) {         ds.sendrequest(config);     } }, 

datasource-polling won't in case because plugin.datatabledatasource doesn't make datatable listen changes in datasource. simple way of polling using plugin.datatabledatasource set interval this:

var datasource = new y.datasource.io(...); var table = new y.datatable(...);  table.plug(y.plugin.datatabledatasource, {   datasource: datasource });  // call load() every second var timer = y.later(1000, table.datasource, 'load', {   request: foo }, true);  // later on, stop polling timer.cancel(); 

the memory leak mention possibility. datatable under ongoing development , better @ managing memory. if have reproducible case , thorough measurements should open issue @ yui's github repository.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -