How do memory leaks occur in JavaScript code then?
The only way to leak memory in JavaScript code is by retaining references to objects that are no longer needed. Assuming that developers are not maliciously doing this, the most common way that such leaks occur in JavaScript code is in the creation of closures that persist certain objects (e.g. function arguments or temporary variables) beyond the scope of a function. With a closure, the objects referenced by the closure survive even after the function returns. If a network of dead objects is kept alive in a closure object which, in turn, is unwittingly or accidentally stored away somewhere persistent (e.g. in the global scope, in a live object, or a timer that is perpetually firing), then that network of dead objects will be kept alive indefinitely. Finding these leaks is usually difficult. But a tell-tale sign that you have such a leak is if you see memory usage growing continually until you throw away your app card (i.e. closing the app document), at which point you see that memory