jQuery $.ajax memory leak?

Why does jQuery ajax cause a horrible memory leak on Firefox & other browsers?

jsfiddle: http://jsfiddle.net/Rqfz7/

If you run this in a browser like Firefox, this causes the memory to climb. Has anyone else seen this? Is there a way to stop the memory leak with jQuery ajax? Thanks

$.ajax({
    url: "http://ws.geonames.org/searchJSON",
    dataType: "jsonp",
    data: {
        featureClass: "P",
        style: "full",
        maxRows: 12,
        name_startsWith: "M"
    },
    success: function( data ) {
        setInterval(function() {
            get_some_stuff();
        }, 1000);
        load_count = load_count + 1;
        $('body h1').text('load_count: ' + load_count);             
    }
})

Answers


I think you want to do SetTimeout instead of SetInterval.

Try this..

http://jsfiddle.net/Rqfz7/2/


It is because you are calling setInterval() from within get_some_stuff() function. setInterval is used to run funciton over and over again at a specified time interval. Your issue is because all those registered functions calls (via setInterval) are executing every second and there are lots of them.


Need Your Help

Getting error from heroku in regards to HTTPS

json angularjs node.js heroku https

I have an app written with angular and deployed over nodejs to heroku.

Redirect all Skype Messages from one profile to another

redirect chat message profile skype

As the title says, is there a way to redirect all skype messages I receive

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.