3 ms·
The fix is to implement the closures properly, by only closing over individual variable slots. It looks like the engines are implementing closures by closing ov
by wahern 9y ago
The fix is to implement the closures properly, by only closing over individual variable slots. It looks like the engines are implementing closures by closing over entire windows of slots--that is, if two functions have the same scope, they inherit the _union_ of the variables they reference as a single window/block of variable slots.
The original article has a much simpler explanation and solution: https://blog.meteor.com/an-interesting-kind-of-javascript-memory-leak-8b47d2e7f156 https://blog.meteor.com/an-interesting-kind-of-javascript-me...
To learn more about closures than you ever thought possible, try reading this paper describing how closures are implemented in Lua: http://www.cs.tufts.edu/~nr/cs257/archive/roberto-ierusalimschy/closures-draft.pdf http://www.cs.tufts.edu/~nr/cs257/archive/roberto-ierusalims...