views:

24

answers:

1

I'm using recursive jQuery AJAX to callback values from the server every second. However, this seems to be incrementing the amount of memory usage my browser has.

I'm using FireFox and I have FireBug installed which I believe to be the culprit as this logs every callback in its Console.

My first question is, am I right in saying this is the case? And if so, is there a way of 'flushing' FireBug every minute or so to reduce the logged callbacks?

Example of my code:

function callBack()
{
    $.ajax(......);
    setTimeout("callback()", 1000);
}

function Init()
{
    callBack();
}

Init();
A: 

Thats not recursion.. it simply calls the same function every second. You may use setInterval to acheive the same thing.

memory leaks usually occurs when you have event handles or dom references that are not freed properly. Check that you dont have references to DOM elements when the AJAX gets triggered. and that you dont reinitialize events for every request.

Quamis
Ah right I didn't realise this wasn't recursion. Thanks
Curt