Memory leak in chrome.extension.sendRequest()
- by jprim
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.