如果在调用setTimeout后没有调用clearTimout,是否存在内存泄漏问题 [英] Is there memory leak issue if not calling clearTimout after calling setTimeout

查看:182
本文介绍了如果在调用setTimeout后没有调用clearTimout,是否存在内存泄漏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用 setTimeout 后,是否存在内存泄漏问题,而没有调用 clearTimeout

After calling setTimeout, is there memory leak issue without calling clearTimeout?

谢谢。

推荐答案

没有。如果要停止发生挂起的setTimeout,则只需要调用clearTimeout。在发生setTimeout之后,计时器id不再有效,但幸运的是,使用无效的计时器id调用clearTimeout是无害的。

No. clearTimeout only needs to be called if you want to stop a pending setTimeout from happening. After the setTimeout happens, the timer id is no longer valid but fortunately calling clearTimeout with an invalid timer id is harmless.

如果发现内存泄漏,则问题出在其他地方。

If you see memory leaks happening the problem is somewhere else.

这篇关于如果在调用setTimeout后没有调用clearTimout,是否存在内存泄漏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆