Hacker News new | past | comments | ask | show | jobs | submit login
MemLab: An open source framework for finding JavaScript memory leaks (fb.com)
124 points by mikece on Sept 13, 2022 | hide | past | favorite | 14 comments



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!


Yup, that's the previous thread :)


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.


Can confirm, have been bitten in production. Therefore we have a lint rule that disallows `console.log` for production builds.


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..."


its incredibly difficult to debug memory leak even with dev tools, I will look into this and hope it helps


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.


That's awesome. Thanks for sharing!


If there is any memory leaks in a garbage-collected language, isn't it a bug of V8 instead?


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.


Very good explanation. I always wondered what is the equivalent of memory leak in a garbage collected language. Are there any tools for this?


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.


My question exactly.


The stuff of nightmares




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: