Skip to content
Discussion options

You must be logged in to vote

The Driver() isn't a context manager format, so you can't guarantee all resources being freed until the Python program terminates.

Use the SB() format to guarantee resources being freed at the end of the with block:

from seleniumbase import SB

with SB(uc=True) as sb:
    sb.open(URL)
    # ...

You can also try the Pure CDP Mode, which has less memory usage because it doesn't use Selenium/WebDriver at all:

from seleniumbase import sb_cdp

sb = sb_cdp.Chrome(url)
sb.open(URL)

You can use objgraph to profile the memory usage. Here's an example with the Pure CDP (sb_cdp) format:

import objgraph
from seleniumbase import sb_cdp

print("\nBefore opening the browser:")
objgraph.show_growth(limit=50

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants