Last active
June 14, 2020 06:22
-
-
Save adam-p/6928614 to your computer and use it in GitHub Desktop.
memory-leak-extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="backgroundscript.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How is it installed?