Skip to content

Instantly share code, notes, and snippets.

@adam-p
Last active June 14, 2020 06:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save adam-p/6928614 to your computer and use it in GitHub Desktop.
Save adam-p/6928614 to your computer and use it in GitHub Desktop.
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

How is it installed?

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