TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Does JavaScript's setInterval() method cause memory leak?

23 pointsby killahpriestover 12 years ago

4 comments

ajanuaryover 12 years ago
From what I can tell the issue stems from the fact that Javascript puts stack frames on the heap, which means the heap will grow with every function call, which they're doing every 50 ms.
checkerover 12 years ago
If it was an issue, wouldn't it be engine- or browser-specific?
评论 #5208378 未加载
ballootover 12 years ago
This is silly. You're creating a new anonymous function on every interval, so it will increasingly take up memory to hold these anon functions until the GC kicks in. It's doing exactly what it should do, because you don't want it doing GC every 50 ms.
评论 #5207903 未加载
评论 #5207858 未加载
评论 #5207859 未加载
malux85over 12 years ago
tl;dr : "No"