Eugene Barsky
Eugene Barsky

Reputation: 6012

How to limit puppeteer browser memory usage

I've tried both variants and neither of them works.

    const browser = await puppeteer.launch({
        args: [
            '--max_old_space_size=1024',
        ],
        headless: true,
    });

and

    const browser = await puppeteer.launch({
        args: [
            '--js-flags="--max_old_space_size=1024"',
        ],
        headless: true,
    });

What am I doing wrong?

Upvotes: 2

Views: 6259

Answers (1)

theDavidBarton
theDavidBarton

Reputation: 8841

I am not sure if it gonna work as the max. memory usage that can be set varies between platforms, but about the syntax I am sure you should use dashes instead of underscores in --max-old-space-size if you try to set it via --js-flags:

await puppeteer.launch({ headless: true, args: [ '--js-flags="--max-old-space-size=1024"' ] });

Upvotes: 3

Related Questions