Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nodriver] Memory leak using with Chrome, Edge & Brave #1851

Open
Abdelrahman-Hekal opened this issue Apr 29, 2024 · 9 comments
Open

[nodriver] Memory leak using with Chrome, Edge & Brave #1851

Abdelrahman-Hekal opened this issue Apr 29, 2024 · 9 comments

Comments

@Abdelrahman-Hekal
Copy link

Abdelrahman-Hekal commented Apr 29, 2024

Good day @ultrafunkamsterdam
Thanks for the amazing nodriver project, I'm experiencing a continuous memory leak on a larger project when using nodriver and I tested this leak over the sample code below and as long as the code is running, it is leaking memory by 2MB per web page visited which is causing the program to be leaking around 10 GB when left running for 8 hours.

The code ran on Windows 11 and Linux where the same behaviour is noticed for both OS.

import nodriver as uc
import asyncio

async def main():

    url = "https://www.carrefouregypt.com/mafegy/en/c/NFEGY4000000?currentPage="
    browser = await uc.start(browser_args=["--incognito"])
    for i in range(1, 100):
        page, content = None, None
        page = await asyncio.wait_for(browser.get(url + str(i)), timeout=30) 
        content = await asyncio.wait_for(page.get_content(), timeout=30) 

uc.loop().run_until_complete(main())

@ilike2burnthing
Copy link

#1844

@Abdelrahman-Hekal
Copy link
Author

Thanks @ilike2burnthing for referring to the uc issue but unfortunately the unclosed chrome processes of undetected-chrome is different than this issue with the nodrive package. The issue that I face is a memory leak within the python process itself as shown in the snapshot below.

image

@Abdelrahman-Hekal
Copy link
Author

Abdelrahman-Hekal commented Apr 30, 2024

Update: I have tried three different browsers (Chrome, Brave and Edge) and the memory leak is still observed with all of the browsers so far

@Abdelrahman-Hekal Abdelrahman-Hekal changed the title Memory leak using nodriver with Chrome v124 Memory leak using nodriver with Chrome, Edge & Brave Apr 30, 2024
@ilike2burnthing
Copy link

There are a few other open issues pertaining to leaks, though again they seem to be for UC:

As a test, try reverting to Chrome v119 and v115. If you need clean installers (check the signatures, they're legitimate offline Chrome installers) - https://filecr.com/windows/google-chrome/?id=847089664000

You'll need to uninstall Chrome first, otherwise it won't install the older version if a newer version is present, and then reinstall normally once done with testing, as it won't auto-update.

@Abdelrahman-Hekal Abdelrahman-Hekal changed the title Memory leak using nodriver with Chrome, Edge & Brave [nodriver] Memory leak using with Chrome, Edge & Brave May 1, 2024
@zuiqinghe2021
Copy link

I encountered the same issue, and switching to an older version of the browser still didn't resolve it. Are there any good solutions?

@jwxce
Copy link

jwxce commented May 10, 2024

Is there a solution to this problem?

@develfe
Copy link

develfe commented May 29, 2024

I noticed the same problem. If I iterate over an array of links, get_content() increases the memory usage of the python process each time. (memory leak).

@life-live
Copy link

Is there a solution to this problem?

image

@Abdelrahman-Hekal
Copy link
Author

@life-live no solution is found yet so far, we highly appreciate it if you can give it some time when possible @ultrafunkamsterdam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants