fnRedraw - detach or empty?

fnRedraw - detach or empty?

HlodvigHlodvig Posts: 5Questions: 2Answers: 1

I'm reloading my table by ajax every 5 seconds. Table contains 1600 rows with pretty complicated cells (data-* attributes, divs, etc) and found out that table update for first 100 or so requests were executed pretty fast (90ms for 1600 rows), but after that it becomes very slow, like 1s, 2s to update table and so on.
I've started to profile it and saw huge memory leak. Like first heap snapshot was 25Mb, after 10 minutes it's 50Mb and so on. After investigating I found out that in function _fnDraw you clear table with the call to body.children().detach();
Well, it's definitely faster than remove(), but memory leak is huge. So I've changed this line to body.empty(); and here you are: no memory leak. First snapshot 25Mb, and next 5 snapshots each 10 minutes are 20Mb...
Well, it didn't fix the problem with sudden slowing of updates, but it solved memory leak.
So the question is - why detaching rows instead of just removing them? Is performance hit is so significant comparing to memory usage?

This discussion has been closed.