4 ms·
Yeah. I thought so too (and still think so). SO post: https://stackoverflow.com/questions/19798803/how-javascript-closures-are-garbage-collected https://stacko
by paulddraper 9y ago
Yeah. I thought so too (and still think so).
SO post: https://stackoverflow.com/questions/19798803/how-javascript-closures-are-garbage-collected https://stackoverflow.com/questions/19798803/how-javascript-...
Chrome bug report: http://crbug.com/315190 http://crbug.com/315190
Meteor blog (linked in article): https://blog.meteor.com/an-interesting-kind-of-javascript-memory-leak-8b47d2e7f156 https://blog.meteor.com/an-interesting-kind-of-javascript-me...
Live example (will crash due to memory leak): https://s3.amazonaws.com/chromebugs/memory.html https://s3.amazonaws.com/chromebugs/memory.html
---
The reason this exists in all JS engines is for performance; it's easier to have on context record instead of several.
Other languages do not do this. Off the top of my head: Lua, Java, Scala
- vvanders 9y agoYeah, there's a nice link in the comments on the chrome bug on how Lua does it with upvalues: https://bugs.chromium.org/p/chromium/issues/detail?id=315190#c14 https://bugs.chromium.org/p/chromium/issues/detail?id=315190...
- dingo_bat 9y ago> Live example (will crash due to memory leak): https://s3.amazonaws.com/chromebugs/memory.html https://s3.amazonaws.com/chromebugs/memory.html Happy to report that no crash in Nightly. Edit: No crash in Edge either.
- paulddraper 9y agoIt'll crash Chrome because it puts stricter limits on JS memory. (Or something.) Firefox and Edge won't crash, but you'll be using 3GB+.
- dingo_bat 9y agoYup Firefox was at 3.6GB and edge at 2.8GB.