Flappy
Flappy

Reputation: 72

How do I kill all chromium processes?

I would like to kill all chromium processes created by puppeteer. I would usually properly close all the browsers from the puppeteer package itself but I am using a different package that uses puppeteer at the side. The problem is that the package does not properly close the chromium tab after it is not in use anymore and I want to manually kill the processes as it takes up a lot of memory if I wouldn't have done so.

I am trying to kill all the processes through the fkill package.

I have tried statments like,

fkill('chromium.exe', {force: true, silent: true, tree: true});

fkill('chromium-browser', {force: true, silent: true, tree: true});

I have additionally tried to use browser.close and kill-tabs to no avail.

Upvotes: 1

Views: 3333

Answers (2)

Flappy
Flappy

Reputation: 72

A quick fix to my problem was just giving up on fkill and using Child Process instead. Although the most plausible answer for a sure fix of this is by adding a finally to the library to keep track of each browser suggested by @ggorlen. Both methods work to fix my problem, thanks a lot!

cp.exec(`Get-CimInstance Win32_Process -Filter "Name = 'chrome.exe' AND CommandLine LIKE '%--headless%'" | %{Stop-Process $_.ProcessId}`, {'shell':'powershell.exe'}, function (err, stdout, stderr) {
                if (err) {
                    throw err;
                }
            })

Upvotes: 1

Dovatti
Dovatti

Reputation: 50

Add --single-process --no-zygote on launch for avoiding multiple processes. With --single-process you'll be able to run plugins and browser in the same process both. With --no-zygote puppeteer will not fork children processes by father one.

When doing that if you simply browser.disconnect you will kill all processes then.

Upvotes: 0

Related Questions