ajax polling causing browser memory to increment every time
我想大声告诉你
我想大声告诉你 2017-05-24 11:33:53
0
4
756

ajax polling causes the browser memory to increase each time. I also checked the relevant information and it was said in complete

Complete ajax code:

    var Timer_getlastLog,ajax_flag;
    Timer_getlastLog = setInterval(function () {
        if(ajax_flag==true){
            getLastLog(lastMsgId);
        }
    }, 1000);
    function getLastLog(msgid) {
        ajax_flag = false;
        $.ajax({
            type: 'post',
            dataType: 'json', 
            url: 'url.html', 
            data: {msgid: msgid}, 
            success: function (a) {
                //此处省略其他的业务逻辑
                lastMsgId=a.msgid;
                ajax_flag = true;
            },
         
        });
    }    

Like this, but the memory overhead is still increasing,

Now I have almost run 2 G. Don't know any solution? Ignore sockets for now.

Supplement:
1. On the server side, I use the TP framework, and then I considered giving a while (true) and then a sleep(1); but this resulted in apache memory overhead after repeatedly refreshing the page. A large increase causes congestion and the page cannot be loaded and displayed normally. This also gives me a headache.

2. I refer to http://blog.csdn.net/mlx212/a... This article makes business modifications to this code and does not affect the logic.

我想大声告诉你
我想大声告诉你

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!