My question assumes you are creating a web page that will be displayed for a “long time.” I’m curious as to what are some of the common gotchas that will cause memory leaks when using JQuery/JavaScript in such a scenario? For instance what happens in terms of memory when you call $.remove() on a collection of elements? Thanks!
My question assumes you are creating a web page that will be displayed for
Share
References : Check this for more and an answer on SO.
Memory issues in event registering mechanism MDN
In the first case, a new (anonymous) function is created at each loop turn. In the second case, the same previously declared function is used as an event handler. This results in smaller memory consumption. Moreover, in the first case, since no reference to the anonymous functions is kept, it is not possible to call element.removeEventListener because we do not have a reference to the handler, while in the second case, it’s possible to do