Massive CPU/RAM usage caused by using UserDataDir
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: “puppeteer”: “^3.1.0”, (Updating to latest version didn’t help)
- Platform / OS version: Ubuntu 18.04
- URLs (if applicable): Any URL
- Node.js version: 12.16.3
- Hardware Info: 4690k + 32Gbs of RAM + Puppeteer running on a good SSD
What steps will reproduce the problem?
Adding userDataDir to launch options will produce the problem.
It will make page loads slower, CPU usage much higher and it will start eating RAM.
This happens on a number of pages. Behavior is pretty reliable.
Task manager shows the CPU usage mainly by chrome.
Deleting the dataDir doesn’t change anything
Removing the setting results in dramatically lower CPU usage…
Please include code that reproduces the issue.
const puppeteer = require('puppeteer');
var os = require('os-utils');
//This be a promise ,
const browserPromise = puppeteer.launch({ headless: true,userDataDir: './puppeteer_data' }).then(async browser => {return browser})
function getCpuUsage(){
os.cpuUsage(function(v){
console.log( 'CPU Usage (%): ' + v );
});
}
async function testScrape(url){
console.log('processing: '+url)
let r = Math.random().toString(36).substring(7);
let browser = await browserPromise
getCpuUsage()
let page = await browser.newPage();
await page.goto(url);
console.log('went to url: '+url)
getCpuUsage()
await takeScreenShot(page,r+'initialLoad.png');
getCpuUsage()
}
async function takeScreenShot(page,fileName){
page.screenshot({path: 'screenshots/'+fileName,fullPage: true});
}
async function run(){
await testScrape('https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md')
await testScrape('https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md')
console.log('Donezo')
}
run()
What is the expected result? Expected it to not start abusing my CPU like there’s no tomorrow
What happens instead? It did it anyway.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How to Fix High RAM and CPU Usage in Windows 10
The problem of High RAM and CPU usage in Windows 10 can be fixed by disabling Runtime Broker, changing Memory Management System and...
Read more >How to fix Chrome high CPU usage issue - Setapp
We'll explore some ideas below. Why is Chrome using too much CPU, RAM, and battery? It's likely that the first time you notice...
Read more >High CPU usage of Browser process in Chrome Task manager
This can be some extensions is in process that cause high CPU. 1. Launch chrome 2. Use it ... Launched it with flag...
Read more >How to reduce the CPU and RAM usage while projecting with ...
Here are some actions that you can apply to reduce the high CPU/RAM usage, the following actions have been found beneficial by Teams...
Read more >Why Chromium consumes high CPU in Puppeteer?
Whenever it's used I'm having huge CPU usage. htop shows Chrome at around 95% on a 2 VCPU machine. I'm launching Chrome from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I had exact same issues that you guys mentioned. The solution worked out for me was changing userDataDir path to absolute path. Instead of this:
userDataDir: 'data'use this:userDataDir: '/Users/batu/Desktop/status/data'We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!