Memory leak in chrome.extension.sendRequest()

Posted by jprim on Stack Overflow See other posts from Stack Overflow or by jprim
Published on 2010-12-29T20:49:20Z Indexed on 2010/12/29 20:55 UTC
Read the original article Hit count: 190

Chrome Version : 9.0.597.19 (Build 68937) beta & current stable

I have simplified my code as far as possible. I ended up with the attached extension:

content.js (content script run on every site):
setInterval(function() {
 chrome.extension.sendRequest({ }, function(response) {
  //Do nothing
 });
}, 1);

background.js (background page script):
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
 sendResponse({ });
});

When you install this extension, you can observe it eating up memory extremely fast (I got 90MB in 1 min with 9 tabs opened). You can speed up the process by opening more tabs.

Of course, the extension I am actually developing does not send requests every millisecond, but only every 3 seconds. This just slows it down, though. A user who has run it in the background for a long time with many tabs opened has reported 100MB of memory usage, and I can reproduce it to a less extreme extent, too.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about google