reactdatagrid icon indicating copy to clipboard operation
reactdatagrid copied to clipboard

Out of memory issues and runtime performance problems caused by using JSON.stringify on data source nodes

Open nstoertz opened this issue 4 years ago • 1 comments

Using TreeGrid APIs, I was finding that my browser ran out of memory when trying to load nodes with more than 60 child nodes... the stack trace is coming from JSON.stringify(computedProps.computedNodeCache) here:

https://github.com/inovua/reactdatagrid/blob/0d2ef4a2da776692bc586517abe32ea93b508c02/community-edition/hooks/useDataSource/index.ts#L1008

The problem turned out to be that we were passing an object as part of of nodes that contained a reference to a very large object which was very expensive to stringify.

Here's an extreme example illustrating the problem: https://codesandbox.io/s/affectionate-architecture-5hsio?file=/src/App.js

Suggested solution: I'm not sure of the solution, but one idea would be to only serialize the idProperty of nodes instead of the entire object.

nstoertz avatar Sep 23 '21 20:09 nstoertz

We experienced the same issue using Tree Grid API.

vasyl-hordynskyy avatar Oct 26 '23 16:10 vasyl-hordynskyy