Hi,
Here is the sample of my code.
func abc()
{
summarygrid = new dhtmlXGridObject(“summary_container”); where summarygrid is defined globally.
…
…
summarygrid.init();
summarygrid.loadXMLString(loader.xmlDoc.responseText,func());
//summarygrid.destructor();
}
The problem with this code is that it creates new Objects everytime on the function invocation leaving dangling objects resulting in memory spikes.
I tried to use the summarygrid.destructor().However the data attached to the grid is not visible with the usage of this function.I would want to either destruct the object without destructing the data represented on the screen or create the object only once and re-use the same object on every function call.
This gives me 2 options to lay my code.
if(summarygrid == null)
{
summarygrid = new dhtmlXObject(“summary_container”);
}
or
if(summarygrid == null)
{
summarygrid.init();
}
I am not sure which is the right approach.How do I ensure that my object is not re-created every time on function call or perform a garbage collection ?
Javascript doesn’t allow clear memory directly, call of grid.destructor removed all code and html elements from document, but it will be cleared by garbage collector of IE. Functionality of gargabe collector can’t be controlled directly from js code
>>I would want to either destruct the object without destructing the data represented on the screen or create the object only once and re-use the same object on every function call.
You can reload grid with new structure or data:
mygrid.clearAll(header) //deletes all rows in grid, header - (boolean) enable/disable (true/false) cleaning header
mygrid.loadXML(“gridH.xml”);// load grid with new data or new structure.