IE内存泄漏-settimeout、重复设置innerHTML
我有一个应用程序每 60 秒重绘页面的一部分。重绘会导致 IE 中出现严重的内存泄漏。
我尝试使用 settimeout/setinterval 来设置重绘计时器。
我还尝试了许多建议的技巧,例如
- 设置innerHTML =''而不是使用jquery删除/空。
- 在重绘 HTML 之前删除所有事件处理程序。
- 在清空父容器之前删除所有子节点。
- 将outerHTML 设置为clear 而不是innerHTML
尽管有这些,我仍然可以看到很大的内存泄漏。 MS 知识库文章似乎表明 IE 8 本质上存在泄漏,我们需要应用修补程序:http://support .microsoft.com/kb/975623
但是,我也在 IE7 和 Firefox 中看到了这个问题,程度非常小。
任何帮助将不胜感激。
谢谢, 苏钦
I have an application which redraws a portion of the page every 60 seconds. The redraw causes major memory leaks in IE.
I tried using both settimeout/setinterval to set the redraw timer.
I also tried many of the tips suggested like
- setting innerHTML = '' instead of using jquery remove/empty.
- Removing all event handlers before redrawing HTML.
- Deleting all child nodes before emptying the parent container.
- Setting outerHTML to clear instead of innerHTML
In spite of all these I can see a big memory leak. MS KB article seems to indicate that IE 8 is inherently leak and we need to apply a hotfix: http://support.microsoft.com/kb/975623
But, I have seen this issue in IE7 as well and in firefox to a very small level.
Any help would be greatly appreciated.
Thanks,
Suchin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你提到的所有选项都值得一试,你是否也尝试过先添加DOM元素,然后再设置innerHTML?
这是一个例子
http://ecmascript.stchur.com/blogcode/ie_innerhtml_memleak/noleak.html
那家伙的解决方案
你是如何删除所有处理程序的?你用过类似Crockford的净化溶液吗?
http://javascript.crockford.com/memory/leak.html
All the options you mentioned are worth the shot, have you also tried adding the DOM element first, and then setting the innerHTML later?
Here is an example
http://ecmascript.stchur.com/blogcode/ie_innerhtml_memleak/noleak.html
And the guy's solution
How did you remove all the handlers? did you use something like Crockford's purge solution?
http://javascript.crockford.com/memory/leak.html