开发者

Prevent Recursive jQuery AJAX incrementing browser memory usage

开发者 https://www.devze.com 2023-01-18 02:50 出处:网络
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 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()"开发者_JAVA百科, 1000);
}

function Init()
{
    callBack();
}

Init();


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.

0

精彩评论

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