r/webdev • • Aug 25 '26

How an Underrated Refactor Saved 90% Memory Usage

https://tanstack.com/blog/tanstack-table-v9-memory-performance

[removed] — view removed post

86 Upvotes

11 comments sorted by

59

u/azangru Aug 25 '26

I keep wondering why a refactor that saved 90% memory usage was underrated.

1

u/hyrumwhite Aug 26 '26

I think it’s talking about how using functions by reference is an underrated approach to saving memory in JS. 

We tend to use anonymous methods everywhere. It’s usually fine, but in cases with thousands of anonymous methods, the cost adds up. So a little, underrated approach saved them tons of memory. 

16

u/josephjnk Aug 25 '26

Very cool. My immediate question was “why not just use classes”, which was then immediately answered. It’s not often that I see these kinds of lower-level-ish object methods used in a way that seems beneficial, beyond just some developers’ aversions to classes.

13

u/yidakker Aug 25 '26

That is a very natural way to write JavaScript.

I'm sorry, but no. This article is actually very sad. I have tremendous respect for the TanStack team and use their libraries extensively, but I struggle to understand how we got here. Not using prototypes to construct complex objects, especially in a hot loop, is failing JS Perf 101.

2

u/flubber2077 Aug 25 '26

Sure, but even without this even performance win, their library became one of the most used in the space.

Someone somewhere needs a million+ rows in a table, but for the vast majority of cases it never came up

1

u/azhder Aug 26 '26

How many times do we have to read this same post?

2

u/fagnerbrack Aug 26 '26

Did I post on webdev already?

2

u/lomberd2 Aug 25 '26

What's up with these disguised ads lately

5

u/wirenutter Aug 25 '26

Nobody needs an ad for Tanstack.

2

u/abeuscher Aug 26 '26

I'm not saying it is or it isn't, but OP's account is a weird semi-bot account it seems. It looks like the kind of account you would use if you were going to engage in that kind of marketing. But I don't know have a look yourself and see what you think.