jasper182 Posted January 14, 2007 Share Posted January 14, 2007 I've recently been working with some javascript on a project and I am not very experienced with it. Anyways, I'm working with doing some simple AJAX, but there is a memory leak somewhere in my page. After 20 minutes or so FF gets extremely sluggish and needs to be restarted. I make sure to delete all variables that are created inside of called functions, but other then that I was wondering what else I should look for to stop these memory leaks. Thanks in advance for any help you can offer me. Quote Link to comment Share on other sites More sharing options...
mainewoods Posted January 14, 2007 Share Posted January 14, 2007 as I understand it, the biggest danger of memory leaks is when you use anonymous functions, ie:[code]function x() { return function () { return 5; } //anonymous function}element.onclick = function () { alert('hello'); } // another anonymous function[/code] Quote Link to comment Share on other sites More sharing options...
fenway Posted January 15, 2007 Share Posted January 15, 2007 Yes, all that stuff about closures between JS and the DOM... Quote Link to comment Share on other sites More sharing options...
mainewoods Posted January 15, 2007 Share Posted January 15, 2007 The closure concept is the most difficult javascript concept I've come across by far. In the last month I have read maybe a dozen articles on closures and memory leaks and I still have not gotten a good handle on it. It seems that the ways in which you can go wrong with closures is numerous and can be devilously sutle. I think there are many large web sites that have leak problems. I have been suspicous for some time that even google pages have a leaking problem because of increased browser lookups I get after using their site.Is anybody aware of a study someone might have done of memory leaking on major web sites? I'd be interested in seeing that. It would seem that you should be able to just use a leaking tool on their web pages without having to have access to their servers. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 16, 2007 Share Posted January 16, 2007 I'll try and post some concrete, real-world examples of the closure issue when I find the time, and sticky it, perhaps. Quote Link to comment Share on other sites More sharing options...
kael.shipman Posted November 29, 2007 Share Posted November 29, 2007 I know this is kind of old, but this is still a big issue for me. Anyone have any resources? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.