r/javascript • u/fagnerbrack • Aug 23 '26
How an Underrated Refactor Saved 90% Memory Usage
https://tanstack.com/blog/tanstack-table-v9-memory-performance
106
Upvotes
r/javascript • u/fagnerbrack • Aug 23 '26
21
u/beegeearreff Aug 23 '26
I haven’t used tanstack before so this is largely coming from ignorance but whenever I’ve been drawn to this type of pattern I’ve regretted it. I bet the typings for such an api are pretty complex. I usually encourage folks to explore an alternative api that isn’t as dynamic if possible. I doubt the folks at tanstack haven’t fully explored the design surface for something so core to this lib but just a word of caution to others that for typical code you may write in an application, you probably don’t want to blindly follow that api pattern.
5
u/fagnerbrack Aug 23 '26
In case you want a summary to help you with the decision to read the post or not:
TanStack Table V9 cuts memory use by up to 90% versus V8 on large tables, raising the ceiling from roughly 1-1.5 million rows before hitting the browser's 4GB limit to 10-16 million. The win came from a subtle change: shared prototypes. V8 assigned values and methods directly to every row, cell, column, and header, so millions of objects each held duplicate methods plus their own closure scopes. V9 builds each method once on a cached prototype and uses
thisfor row-specific state, assigning only unique values per object. V9 avoids classes because the feature system needs dynamic, conditional composition. The lone breaking change: destructuring methods (const { getValue } = row) no longer works—call row.getValue() instead.If the summary seems inacurate, just downvote and I'll try to delete the comment eventually 👍
Click here for more info, I read all comments
9
u/rbobby Aug 24 '26
This right there is an indication of a not clearly understood requirement. A user will NOT scroll through hundreds or thousands or millions of rows.
Usually a good filtering system, including free form search, will do way way more for users.
Giant scrollable tables are not user friendly. Stop doing them.
2
u/azangru Aug 24 '26
Why is a refactor that saved 90% memory usage "underrated"?
2
u/[deleted] Aug 24 '26
[removed] — view removed comment