Destroying and Reloading a DataTable

Destroying and Reloading a DataTable

thecountofzerothecountofzero Posts: 21Questions: 0Answers: 0
edited April 2013 in General
Allan,

I am currently implementing the following pattern.

1. Fetch data from the server
2. Using a JS templating engine (EJS) I generate the HTML for a table
3. Then I convert the table to a DataTable using .dataTable()

This works very nicely.

Here's my issue/concerns:

My page polls and every 30 seconds, it fetched a fresh dataset from the server.

In order to update the table I am doing the following:

1. Calling fnDestroy to destroy the table
2. Clearing out the DOM Element containing the HTML table using element.empty()
3. Recreating the HTML table
4. Converting it to a DataTable again using .dataTable()

Once again, this seems to work nicely.

My concerns are that this pattern appears to be leaking memory. Can you think of any reasons why this would be happening?

Does calling fnDestroy() clean up all event handlers and clear a references to ensure the garbage collector can do its job?

What are your thoughts, comments and suggestions?

I have been using DataTables for a few years now and I think it is awesome.

Thanks!
This discussion has been closed.