Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
memory-leak-extension
<script src="backgroundscript.js"></script>
chrome.runtime.onMessage.addListener(function(request, sender, responseCallback) {
if (request === 'synch-req') {
responseCallback(true);
return false;
}
else if (request === 'asynch-req') {
setTimeout(function() { responseCallback(true); }, 1);
return true;
}
else {
console.log('Unmatched request', request);
}
});
function synchReq() {
chrome.runtime.sendMessage('synch-req', function(response) {
if (response !== true) {
console.log('synchReq response not true');
}
});
}
setInterval(synchReq, 2000);
function asynchReq() {
chrome.runtime.sendMessage('asynch-req', function(response) {
if (response !== true) {
console.log('asynchReq response not true');
}
});
}
setInterval(asynchReq, 2000);
{
"manifest_version": 2,
"name": "Memory Test Extension",
"version": "0.0.1",
"description": "",
"homepage_url": "https://github.com/adam-p/markdown-here",
"minimum_chrome_version": "6",
"permissions": [],
"background": {"page": "background.html"},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": [
"contentscript.js"
]
}
]
}
Test extension to demonstrate possible memory leak in Chrome extension API.
Install it, open a bunch of tabs, open Chrome's task manager, let it run, watch memory usage increase.
@javadhemati
Copy link

javadhemati commented Jun 14, 2020

How is it installed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment