Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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/

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.



> 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.


There 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/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: