I have a web app that destroys and creates a DataTable with a button click. To remove the DataTable I'm using the jQuery .html() method which guarantees that it
When the TableTools plugin is being used, it stores references to aoData in, from what I’ve seen, multiple locations. So when I clear the current DataTable and create a new one the aoData array from the old table is still referenced by TableTools which creates a memory leak. At first glance, it looked like it was just this instance array keeping the reference to old tables in TableTools.js:
Is there a built-in method to clear the TableTools object to prevent it from referencing removed DataTables data? I’ve tried a few other things including using fnClearTable with no luck.
I appreciate any help!
removes other constructs such as data and event handlers from child elements before replacing those elements with the new content.I confirmed there was no memory leak using this method without TableTools using a combination of Resource Monitor on windows and the Chrome heap snapshot debugging capability.
When the TableTools plugin is being used, it stores references to aoData in, from what I’ve seen, multiple locations. So when I clear the current DataTable and create a new one the aoData array from the old table is still referenced by TableTools which creates a memory leak. At first glance, it looked like it was just this instance array keeping the reference to old tables in TableTools.js:
/** * Store of all instances that have been created of TableTools, so one can look up other (when there is need of a master) * @property _aInstances * @type Array * @default [] * @private */ TableTools._aInstances = [];So my first attempt at fixing the problem was splicing the _aInstance array to remove the first element when I delete the current table:
TableTools._aInstances.splice(0, 1); $('#tableContainer').html(‘’);Unfortunately the aoData array is still being referenced somewhere after doing this so the leak persists.
Is there a built-in method to clear the TableTools object to prevent it from referencing removed DataTables data? I’ve tried a few other things including using fnClearTable with no luck.
I appreciate any help!