[Bug]: Memory leak when switching/initializing agents, probably due to Browser
Is there an existing issue for the same bug?
- [X] I have checked the troubleshooting document at https://opendevin.github.io/OpenDevin/modules/usage/troubleshooting
- [X] I have checked the existing issues.
Describe the bug
If you open the settings modal repeatedly, and switch your settings up to cause a re-init of the agent, the server slowly consumes more and more memory
I had to do this ~50 times before my machine became unresponsive.
When I finally quit, I get a bunch of logs like this:
11:47:33 - opendevin:INFO: browser_env.py:69 - Browser env process interrupted by user.
11:47:33 - opendevin:INFO: browser_env.py:69 - Browser env process interrupted by user.
11:47:33 - opendevin:INFO: browser_env.py:69 - Browser env process interrupted by user.
11:47:33 - opendevin:INFO: browser_env.py:69 - Browser env process interrupted by user.
11:47:34 - opendevin:INFO: browser_env.py:69 - Browser env process interrupted by user.
INFO: Shutting down
11:47:34 - opendevin:INFO: browser_env.py:69 - Browser env process interrupted by user.
INFO: Waiting for background tasks to complete. (CTRL+C to force quit)
11:47:34 - opendevin:INFO: browser_env.py:69 - Browser env process interrupted by user.
Current Version
On main
commit ce7c7eaae45ce18a13081e63d013a7123bbe95d3 (HEAD -> main, origin/main, origin/HEAD)
Author: Robert Brennan <[email protected]>
Date: Thu May 2 11:44:54 2024 -0400
Refactor actions and observations (#1479)
### Installation and Configuration
```bash
Running in dev mode
Model and Agent
Various models and agents as I switched around
Reproduction Steps
- Fire up the UI
- Open settings modal
- Change something and save
- Repeat ~50 times
- Your machine will grind to a halt
Logs, Errors, Screenshots, and Additional Context
No response
@frankxu2004 any immediate thoughts here? I'm not 100% sure it's the browser, but it seems like the most likely culprit
Most likely the browser env processes are not closed. Would you mind ps -aux | grep playwright when you have a lot of initialization of agents? I will take a look later today.
Can reproduce. Every time it re-initializes the agent, a new AgentController is initialized, a new BrowserEnv is created, and thus the underlying browser process. The old AgentController instances are not GCed as their sid still seem valid. I am not 100% sure but I wonder what happened to the previous sessions?