Zenika / alpine-chrome

Chrome Headless docker images built upon alpine official image
https://hub.docker.com/r/zenika/alpine-chrome
Apache License 2.0
1.85k stars 243 forks source link

Uncontrollable memory usage #172

Open rileyai-dev opened 3 years ago

rileyai-dev commented 3 years ago

Context

I have a NodeJS app which uses puppeteer to scrape an infinite page. While scrolling, I remove the DOM loaded in order to reduce the memory used by puppeteer. When I run the app with puppeteer on my MacOS, it uses 500MB to 800MB but when I run it on zenika/alpine-chrome:89-with-node, it goes up to 2.7GB.

I have the following arguments for the MacOS application: '--js-flags=--expose-gc', '--single-process', '--no-zygote', '--no-sandbox', '--ignore-certificate-errors'

and the ones for the alpine: '--js-flags=--expose-gc', '--single-process', '--no-zygote', '--no-sandbox', '--headless', '--disable-gpu', '--ignore-certificate-errors'

For information, the alpine docker runs on Kubernetes which allows me to see in real time the memory used.

Alternatives

Why is it taking so much memory? Is there a way to reduce it? Is there anything I can do to gather enough information to understand what's going on?

jlandure commented 3 years ago

Hi @grapevineai 👋

Thanks for the issue 👍

I don't know so much why/how Chrome is using so much memory... If you had limitations to your pod (to 800MB for example), does it work?

rileyai-dev commented 3 years ago

@jlandure My pod has a memory limit and when it is reached, the pod is evicted. The problem is how can I contain the memory usage of Chrome?

jlandure commented 3 years ago

Hi @grapevineai 👋

Sorry for the delay... Any news about this issue? Did you succeed? 😊

rileyai-dev commented 3 years ago

@jlandure Unfortunately no... I tried with different distros but got the same issue. I'd be happy to give a https://issuehunt.io/ bounty for anyone who can solve this problem!