-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Fix #16407: Address 32-bit Chrome out-of-memory errors in Python bindings #16408
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
Conversation
…ython bindings This commit addresses out-of-memory errors that occur when using 32-bit Chrome with large extensions (like OKX wallet) on Windows, as reported in issue SeleniumHQ#16407. Root Cause: 32-bit Chrome has a per-tab memory limit of approximately 1GB. When extensions consume significant memory, opening new tabs can exceed this limit, causing out-of-memory errors and connection timeouts between Selenium and ChromeDriver. Implemented Solution: 1. Added garbage collection triggers at critical points: - After closing windows/tabs (close method) - Before opening new windows on 32-bit systems (switch_to_new_window method) - After quitting the driver (quit method) 2. Enhanced session cleanup in quit method: - Iteratively closes all window handles before final quit - Prevents orphaned windows from holding memory - Includes exception handling to ensure cleanup completes 3. Added platform detection and warning: - Detects 32-bit Chrome on Windows during initialization - Logs warning about 1GB per-tab memory limitation - Advises upgrading to 64-bit Chrome - Includes documentation in class docstring Technical Details: - Imports gc, logging, and platform modules - Overrides quit, close, and switch_to_new_window methods - Maintains backward compatibility with existing code - Exception handling ensures robustness This implementation helps prevent the timeout issues described in the bug report by proactively managing memory and providing clear warnings to users about platform limitations.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to force garbage collection, you can do it in your own subclass of webdriver, but we aren't adding this... sorry.
Related Issues
Fixes #16407
What does this PR do?
This PR addresses out-of-memory errors that occur when using 32-bit Chrome with memory-intensive extensions (such as OKX wallet) on Windows. The issue manifests as connection timeouts between Selenium and ChromeDriver when tabs exceed the 1GB per-tab memory limit of 32-bit Chrome.
Bug Description
When using 32-bit Chrome on Windows with large extensions:
Implementation Notes
Root Cause:
32-bit Chrome enforces a per-tab memory limit of approximately 1GB. Memory-intensive extensions combined with new tab creation can exceed this limit, causing renderer crashes and connection failures.
Solution:
Proactive garbage collection - Triggers Python GC at critical points:
Enhanced session cleanup - Improved quit method:
Platform detection and warnings:
Technical Implementation:
Additional Considerations
Testing:
Follow-on work:
Limitations:
Types of changes
Contributing Guidelines
This contribution follows the project's contributing guidelines, adheres to the code of conduct, and respects the security policy.
PR Type
Bug fix
Description
Fix 32-bit Chrome out-of-memory errors with garbage collection
Add platform detection and memory limit warnings
Enhance session cleanup in quit method
Improve memory management for window operations
Diagram Walkthrough
File Walkthrough
webdriver.py
Enhanced Chrome WebDriver with memory management
py/selenium/webdriver/chrome/webdriver.py
gc
,logging
, andplatform
modulesquit()
,close()
, andswitch_to_new_window()
methods