Simple jQuery Ajax call leaks memory in Internet Explorer

后端 未结 8 809
小鲜肉
小鲜肉 2020-12-02 20:33

I created a web page that makes an Ajax call every second. In Internet Explorer 7, it leaks memory badly (20 MB in about 15 minutes).

The program is very simple. It

8条回答
  •  遥遥无期
    2020-12-02 20:42

    if you're using the setinterval in javascript and don't clear it properly, the timer can start multiple times, causing a stack of calls.

    try something like

    var myVar = setInterval(function() { clear() }, 5000);
    
    function clear() { 
        clearInterval(myVar); 
        GetData("ServiceLibrary","GetCalls",sdata,Complete);
    };
    

提交回复
热议问题