I'm seeing fairly massive memory leaks in long-lived pages using Chrome's chrome.extension.sendMessage()
After sending ~200k events from the Content-Script to the Background-Page as a test, chrome.Event's retained size is ~80% of the retained memory in ~50MB heap snapshot
I've been trying to track down any mistakes I might be making, closing over some variable and preventing it from being GC'd, but it seems to be related to the implementation of Chrome's eventing system
Has anyone run into anything like this, or seen memory leaks with extremely long-lived extensions with Content-Scripts that chatter a lot with a bg page?
The code on my Content-Script side:
csToBg = function(message) {
var csToBgResponseHandler = function(response) {
console.log("Got a response from bg");
};
var result = chrome.extension.sendMessage(null, message, csToBgResponseHandler)
};
And on the Background-Page side, a simple ACK function (to superstitiously avoid https://code.google.com/p/chromium/issues/detail?id=114738):
var handleIncomingCSMessage = function(message, sender, sendResponse) {
var response = message;
response.acked = "ACK";
window.console.log("Got a message, ACKing to CS")
sendResponse(response);
}
After sending ~200k messages in Chrome 23.0.1271.97 this way, the heap snapshot looks like:
The memory never seems to get reclaimed for the life of the page, and I'm stumped about how to fix it.
EDIT: This is a standard background page, and is not an event page.
This is probably fixed in chrome 32.
see http://code.google.com/p/chromium/issues/detail?id=311665 for details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With