最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I track and debug JavaScript memory leaks in Firefox? - Stack Overflow

programmeradmin2浏览0评论

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:

/

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:

.js

Any ideas as to what is causing the memory leak? The weird thing is this code behaves properly under IE7.

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:

http://www.abcavendre.com/4506691919/

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:

http://www.abcavendre.com/Vitrine/Israel_Huttman/

You can see the source of the script in question here:

http://www.abcavendre.com/scripts/showcase_small.js

Any ideas as to what is causing the memory leak? The weird thing is this code behaves properly under IE7.

Share Improve this question edited Oct 27, 2009 at 0:00 Bill the Lizard 406k211 gold badges572 silver badges889 bronze badges asked Oct 14, 2008 at 11:46 Andrew MooreAndrew Moore 95.4k30 gold badges166 silver badges175 bronze badges 3
  • Did you solved it? If yes, what was the problem? – Daniel Silveira Commented Oct 15, 2008 at 2:26
  • I did not manage to solve it. I am getting valuable information from the Leak Monitor Addon. I'm still working on it. – Andrew Moore Commented Oct 15, 2008 at 4:08
  • 7 Disable Firebug if its enabled in any way. – leppie Commented Oct 17, 2008 at 10:50
Add a comment  | 

3 Answers 3

Reset to default 8

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.

Update to MooTools 1.2.1, we've improved garbage collection and leak handling.

Try nulling elements variable array in the end of the initialize function

    ...

    if (ads.length > 0)
        {
        this.imagesFx = new Fx.Elements(elements,
            {
            wait: false,
            duration: 1000
            });
        this.moveNext.periodical(2500, this);
        }

    elements = null; //Add THIS!
}
发布评论

评论列表(0)

  1. 暂无评论