Chrome extension memory leak in chrome.extension.sendMessage ()?

I see quite massive memory leaks on long-lasting pages using Chrome chrome.extension.sendMessage ()

After sending ~ 200k events from Content-Script to the background image as a test, the chrome.Event saved size is ~ 80% of the stored memory in the ~ 50 MB heap snapshot

I tried to track any errors that I could make by closing some kind of variable and not letting it be GC'd, but it seems to be related to the implementation of the Chrome event system

Has anyone come across anything like this or seen memory leaks with extremely long-lived extensions with Content-Scripts that often chat with the bg page?

Code on my Content- Script page:

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 Side-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 snapshot looks like: heap snapshot

It seems that memory is never recovered for the life of the page, and I don’t understand how to fix it.

EDIT: This is a standard man page and not an event page.

+8
google-chrome google-chrome-devtools google-chrome-extension
source share
1 answer

Perhaps this is fixed in chrome 32.

Finally!

See http://code.google.com/p/chromium/issues/detail?id=311665 for details

+1
source share

All Articles