开发者

how to avoid memory leaks caused by dijits?

I'm new to dojo and currently having some problems with significant memory leaks. Since I read that the JavaScript garbage collector might have problems with dijits that haven't been destroyed, I'm trying to take care of that, but haven't been too successful.

So first I'm trying to get rid of all widgets, when the page is being left:

dojo.addOnWindowUnload(function(){
    dijit.registry.forEach(function(widget){
        widget.destroy();
    });
});

This seems to help a bit, but not as much as I would have expected. So at certain stages I call:

dojo.forEach(dijit.findWidgets(node), function(widget){
    widget.destroyRecursive();
});

But I'm still having memory leaks pretty sure caused by dijits somehow. Are there any general tips and best practices how to get rid of such? Or should the calls above be able to take care of e开发者_如何学Goverything and I have to look somewhere else for the leaks? Well, I know it's a pretty general question, but I hope you can give me some hints anyway.

Thanks!


You shouldn't need to do this yourself - see http://trac.dojotoolkit.org/browser/tags/release-1.5.0/dijit/_base/manager.js#L293.

If you're having memory leaks once you've destroyed the page or tab then it's most likely a bug in Dijit. Please make a minimal test case and submit a ticket to trac, or paste it here and I'll take a look and/or pass it over to someone who might be able to help.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜