Some of the Shiny apps we’ve developed for a financial trading firm have pretty consistent requirements:
- Show a lot of data, and highlight the important stuff.
- Update that data frequently.
The DataTables library makes a lot of sense for those. It’s easy to use – just pop in a data.frame and by default you have a sortable, searchable, page-able table with a nice default style.
But then we noticed the client-side (browser) memory leak!
Over the course of 20 minutes, we saw the Javascript heap grow from 10-15 MB to 100+ MB, and keep on going.
Eventually the browser tab would crash, and the app had to be restarted.
After investigating, we noticed the server-side rendering function DT::renderDataTable
actually creates a NEW instance of the DataTable every time it updates, rather than just updating the data in the existing table.