开发者

Does setInterval leak?

i'm doing some javascript, where I repeadetly click a button, using

setInterval(function(){
    clickmyButton()
}, 500);

Eventually clickmyButton will send the user to another 开发者_运维技巧page (via window.location.href="Other page"). I was wondering, since I never called clearInterval within the function will it cause a leak? I just assumed that since the page goes to another page, the javascript on the old page will stop running and be cleaned up.


That is correct. Once the page closes, all the javascript running is discarded, and all of the memory associated with its variables is cleared.


It shouldn't. The memory occupied should be set to overwritable or cleared on the new page load.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜