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

Fix resource leaks #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

clayton-shopify
Copy link

@clayton-shopify clayton-shopify commented Sep 8, 2021

After quitting a local Chrome session, two threads (one running cleanup_async_responses, and one running process_messages) continue executing forever. This uses up memory and CPU time. If many sessions are started and quit, all available memory will eventually be consumed.

To demonstrate the problem, run this code and keep the Ruby interpreter running:

10.times do
  session = Capybara.current_session
  session.visit("about:blank")
  session.quit
end

Observe (for instance, using top -H) that 20 threads remain.

To fix the problem, I've added exit conditions to the two problematic loops. I'm not sure whether checking the status of @ws is the best approach, but it works in my testing.

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

Successfully merging this pull request may close these issues.

1 participant