如何在Firefox中跟踪和调试JavaScript内存泄漏? [英] How do I track and debug JavaScript memory leaks in Firefox?
问题描述
我一直试图在一个月内跟踪这个,但没有任何成功。我在汽车广告网站上有这段代码,基本上允许缩略图在搜索结果中旋转,因为汽车有多张图片。您可以在以下操作中看到它:
I've been trying to track this one for literally a month now without any success. I have this piece of code on an car advertising website which basically allows thumbnails to rotate in search results given that a car has multiple pictures. You can see it in action at the following:
它建立在 mootools 1.2 框架。问题是,当一个页面充满了这些旋转图片时,这个脚本在Firefox 3下会消耗相当多的内存,例如这个库存页面:
It is built on the mootools 1.2 framework. The problem is that this script, under Firefox 3, consumes a rather large amount of memory overtime when a page is full of those rotating pictures, such as this inventory page:
你可以看到脚本的来源这里有问题:
You can see the source of the script in question here:
关于什么导致内存泄漏的任何想法?奇怪的是这个代码在IE7下运行正常。
Any ideas as to what is causing the memory leak? The weird thing is this code behaves properly under IE7.
推荐答案
跟踪Firefox内存泄漏的方法是使用泄漏监视器插件。它显示了javascript(包括扩展脚本)的内存泄漏。
A way to track memory leaks in Firefox is with the Leak Monitor Addon. It shows memory leaks of javascript (including extension-scripts).
请提醒该插件有时会显示泄漏的对象,这些对象将在以后通过垃圾回收进行清理。如果是这种情况,插件将启动一个新窗口,显示新状态。
Please remind that the plugin will sometimes show leaked objects that will get cleaned up later by the garbage collection. If that is the case the plugin will launch a new window showing you the new status.
这篇关于如何在Firefox中跟踪和调试JavaScript内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!