Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9239735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:03:25+00:00 2026-06-18T08:03:25+00:00

I have a chrome extension that I built that leaks memory. I am working

  • 0

I have a chrome extension that I built that leaks memory. I am working on fixing the memory leak, but in the mean time a few friends are already using it.

As a temporary measure I want to include a patch which would restart the extension automatically, periodically.

How to do this?, namely restart a chrome extension from within the extension itself.

thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:03:26+00:00Added an answer on June 18, 2026 at 8:03 am

    You can have two extensions. And restart the target extension from the other. If that suits you read on.

    content.js

    window.addEventListener('load', function (e) {
        // create a button and add it to the page
        var btn = document.createElement('button');
        btn.innerHTML = 'Restart child extension';
        btn.addEventListener('click', function (e) {
            // on button click send message to the background script
            chrome.extension.sendMessage({restart: true}, function (res) {
                console.log(res);
            });
        }, false);
    
        var body = document.querySelector('body');
        body.appendChild(btn);
    }, false);
    

    background.js

    // first get your target (child) extension by it's name
    var child = null;
    chrome.management.getAll(function (info) {
        for (var i=0; i < info.length; i++) {
            if (info[i].name == 'Test child extension') {
                child = info[i];
                break;
            }
        }
    });
    
    function disable (cb) {
        chrome.management.setEnabled(child.id, false, cb);
    }
    function enable (cb) {
        chrome.management.setEnabled(child.id, true, cb);
    }
    function afterEnable () {
        // notify the content script
        resRestart({restarted: true});
    }
    
    var resRestart = null;
    chrome.extension.onMessage.addListener(function (request, sender, sendResponse) {
        console.log(request);
        // if we receive request with restart variable, save a reference to the
        // sendResponse function and disable the child extension
        switch (true) {
            case request.restart: resRestart = sendResponse; disable(); break;
        }
        return true;
    });
    chrome.management.onDisabled.addListener(function (extension) {
        // this one is fired when extension is restarted
        // check if this is our child extension and re-enable it
        if (extension.name == 'Test child extension') {
            enable(afterEnable);
        }
    });
    

    manifest.json (parent)

    {
        "manifest_version": 2,
        "name"            : "Test parent extension",
        "version"         : "1.0",
        "description"     : "Whatever",
    
        "background" : {
            "scripts": [
                "background.js"
            ]
        },
    
        "content_scripts": [
            {
                "matches": [
                    "*://localhost/*"
                ],
                "js": [
                    "content.js"
                ],
                "run_at": "document_end",
                "all_frames": true
            }
        ],
    
        "permissions": [
            "tabs",
            "management",
            "*://localhost/*"
        ]
    }
    

    manifest.json (child)

    {
        "manifest_version": 2,
        "name"            : "Test child extension",
        "version"         : "1.0",
        "description"     : "Whatever",
    
        "content_scripts": [
            {
                "matches": [
                    "*://localhost/*"
                ],
                "css": [
                    "style.css"
                ],
                "run_at": "document_end",
                "all_frames": true
            }
        ]
    }
    

    directory structure

    .
    ├── background.js
    ├── child
    │   ├── manifest.json
    │   └── style.css
    ├── content.js
    └── manifest.json
    

    Now open up about:extensions and http://localhost in split screen. Click on the button and see how the child extension is refreshed each time. Also you can check out the console. Even try to disable the child extension from within about:extensions – it’s not possible as long as the parent extension is running.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built the UI for my Google Chrome Extension, but I am trying
A Chrome extension I built a few months ago has been working fine until
I have a Chrome extension that I am working on that will POST data
I am working on creating a Google Chrome extension. We have it included in
I have some sensitive Javascript in a Chrome Extension that I do not want
We have a new extension that we built for many months and is live
We have built a chrome extension and it has crashed a couple of times
I have a chrome extension that uses the facebook Graph API Because its a
I have a chrome extension that I want to port to firefox. In chrome,
I have this chrome extension that shows some content in the popup.html. As the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.