开发者

jquery ajax requests increase of memory

开发者 https://www.devze.com 2023-02-14 18:57 出处:网络
I have an ajax request every 1 second that pulls a JSON from server and manipulate a div. After a while, browser shows a large memory use in task manager about 200, 30开发者_如何学编程0, 500 MB and it

I have an ajax request every 1 second that pulls a JSON from server and manipulate a div. After a while, browser shows a large memory use in task manager about 200, 30开发者_如何学编程0, 500 MB and its still growing. How can I replace new data with old without caching or anything that affect memory?


Try nulling out the existing JSON file before each request, and be sure its writing to the same variable. Is this happening inside a loop? Move the variable outside of the loop and refer to it instead.


Try using cache: false:

$.ajax({
url: "test.html",
cache: false,
success: function(html){
$("#results").append(html);
}
});
0

精彩评论

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

关注公众号