Garbage collection in google-chrome extensions

2019-04-13 00:09发布

I am developing a google-chrome extension that has javascript code that is make xhr requests periodically. I realized that over time, the amount of RAM that the process took up started increasing. I am not sure if this is due to the fact that the xhr requests do not get garbage collected or if it is because google-chrome keeps the response of the xhr request and doesnt get rid of it. Here is some of my code:

var locationx = "http://www.example.com";

var newxhrx = new XMLHttpRequest()

newxhrx.startedOn = new Date().getTime()

try {

      newxhrx.open("GET", locationx, true)

      newxhrx.followRedirects = false

      newxhrx.send(null)

} catch(e1){

      alert('No internet connection')

}

newxhrx = null;

locationx = null;

If I look at the "Network" section in the chrome developer tools. I see that the page is called multiple times and the responses do not get removed from this section. Is this problem due to a JavaScript memory leak or because of google-chrome saving the responses? Can this be fixed and how?

1条回答
相关推荐>>
2楼-- · 2019-04-13 00:55

The growth of memory usage when working with AJAX calls is observed in other browsers as well.

http://forum.jquery.com/topic/memory-leaks-with-ajax-calls

http://code.google.com/p/chromium/issues/detail?id=52411

查看更多
登录 后发表回答