News for hackers. Stuff that matters.
Re:MemLab: An open source framework for finding JavaScript m... by emptysea on Monday September 12, 2022 @08:56PM (#32819453)
Ah I think this was mentioned in a comment on a previous thread:

https://news.ycombinator.com/item?id=29595441

Glad to see it finally open sourced!

Re:MemLab: An open source framework for finding JavaScript m... by lgong on Monday September 12, 2022 @10:46PM (#32820156)
Yup, that's the previous thread :)
Re:MemLab: An open source framework for finding JavaScript m... by latchkey on Tuesday September 13, 2022 @04:13PM (#32829632)
Memory leak because of console.log? Wow, news to me. Not that I really ever use it for much since I believe in writing unit tests over outputting logs to the console. But I can see how others might get bitten by this for sure.
Re:MemLab: An open source framework for finding JavaScript m... by chess_buster on Tuesday September 13, 2022 @05:46PM (#32830550)
Can confirm, have been bitten in production. Therefore we have a lint rule that disallows `console.log` for production builds.
Re:MemLab: An open source framework for finding JavaScript m... by x-shadowban on Tuesday September 13, 2022 @09:57PM (#32832407)
Node heap profiler in chrome is pretty good, often it will show the largest retainers and if your hookes to a live vm (not a snapshot) you can inspect the object and eventually go "oh yeah this array just grows and grows..."
Re:MemLab: An open source framework for finding JavaScript m... by jalino23 on Tuesday September 13, 2022 @05:05PM (#32830176)
its incredibly difficult to debug memory leak even with dev tools, I will look into this and hope it helps
Re:MemLab: An open source framework for finding JavaScript m... by Frotag on Tuesday September 13, 2022 @05:46PM (#32830559)
I learned recently that Edge has a "Detached Elements" panel that identifies leaked DOM elements and the code / object holding the reference.

It basically automates the process of diff'ing heap snapshots.

Re:MemLab: An open source framework for finding JavaScript m... by buttersbrian on Wednesday September 14, 2022 @10:33AM (#32837809)
That's awesome. Thanks for sharing!
Re:MemLab: An open source framework for finding JavaScript m... by maxloh on Tuesday September 13, 2022 @12:01AM (#32820529)
If there is any memory leaks in a garbage-collected language, isn't it a bug of V8 instead?
Re:MemLab: An open source framework for finding JavaScript m... by astrange on Tuesday September 13, 2022 @01:26AM (#32820939)
You can just leak memory by leaving references to it around. Sometimes called memory abandonment.

With some systems you can pin it and forget to unpin it.

Re:MemLab: An open source framework for finding JavaScript m... by fithisux on Tuesday September 13, 2022 @11:50PM (#32833141)
Very good explanation. I always wondered what is the equivalent of memory leak in a garbage collected language. Are there any tools for this?
Re:MemLab: An open source framework for finding JavaScript m... by astrange on Wednesday September 14, 2022 @01:14AM (#32833552)
Well, there’s the one in the article. Usually each GC implementation comes with its own tools.

You can watch process memory in general and see if keeps going up; if it does, it’s someone’s fault.

Re:MemLab: An open source framework for finding JavaScript m... by fithisux on Tuesday September 13, 2022 @11:49PM (#32833137)
My question exactly.
Re:MemLab: An open source framework for finding JavaScript m... by darepublic on Wednesday September 14, 2022 @12:44AM (#32833415)
The stuff of nightmares