4 ms·
Really bad use of javascript can cause a memory leak in browser.
by ankitml 12y ago
Really bad use of javascript can cause a memory leak in browser.
- falcolas 12y agoDoesn't even have to be that bad of a use, appending an item to a long-lived list and never popping it is all that it would take. Garbage collection != memory leak proof
- disputin 12y agoSo why did flip get down voted, and not Jacques?
- falcolas 12y agoI personally blame human nature. Jacques is a known/respected name around HN, so since the OP was downvoted at least once (enough to make the text harder to read), and a HN personality posted a "are you crazy" response, the typical action taken is a quick "downvote OP, upvote personality". The problem with downvotes in HN is the side effects. An early downvote can mean nothing more significant than "I disagree with you", but it has the effect of making a post significantly harder to read. When a post is hard to read, fewer people will read the post, yet they are willing to accept and re-enforce the judgement of their peers (especially HN personalities) without critically reviewing it for themselves. I wouldn't personally blame Jacques for this, but his dismissal (and possibly the early downvote as well) has had a net negative effect on the OP, regardless of the OP's correctness. EDIT: And our sin appears to be getting too meta. Cardinal sin, that.
- disputin 12y agoBad meta. Sorry to lure you into it. I'll vote you back up.
- jacquesm 12y agoThat's also not a memory leak. A memory leak is a chunk of memory that is allocated and never freed when it should have been. So let's say this 'terrible' javascript page allocates 2G of RAM. If you refresh the page and the memory stays allocated that is a memory leak. But if it frees it and then reallocates it then it is not a memory leak but just working as designed to (as is your example above). Memory leaks are not properties of websites but properties (or rather hopefully not) of browsers indicating a bug in the browsers code, no website should be able to cause a browser to leak memory and if such websites can be found bugs should be logged against those browsers that can be reproducibly caused to lose track of their memory allocation. It's not all that hard.