4 ms·
I'm not a JavaScript expert, and so I didn't understand this bit: > create a circular reference and thus, a memory leak It was confusing because JavaScript us
by wzdd 15y ago
I'm not a JavaScript expert, and so I didn't understand this bit:
> create a circular reference and thus, a memory leak
It was confusing because JavaScript uses mark-and-sweep collection, which can handle circular references just fine.
A bit of googling turns up this link, which explains it:
http://www.ibm.com/developerworks/web/library/wa-memleak/ http://www.ibm.com/developerworks/web/library/wa-memleak/
The problem is that the DOM is reference counted (at least in some browsers, at least back when that article was written). So, you can get memory leaks in cases where JS intersects with the DOM.
- stanleydrew 15y agoThere is a better explanation at the very end of this awesome description of javascript's closures and scope resolution: http://jibbering.com/faq/notes/closures/ http://jibbering.com/faq/notes/closures/
- masklinn 15y ago> so I didn't understand this bit: That's because it's wrong. > It was confusing because JavaScript uses mark-and-sweep collection, which can handle circular references just fine. I don't think that's mandated, you could probably implement a refcounted JS interpreter. > The problem is that the DOM is reference counted (at least in some browsers, at least back when that article was written). So, you can get memory leaks in cases where JS intersects with the DOM. And the main culprit was, as is usually the case, Internet Explorer.