-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Clear terminal output buffers to prevent memory leaks #7666
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
base: main
Are you sure you want to change the base?
Clear terminal output buffers to prevent memory leaks #7666
Conversation
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.
Thank you for working on this memory leak fix! I've reviewed the changes and found some critical issues that need to be addressed before this can be merged. The main concern is that the memory leak may not be fully resolved due to the implementation logic.
- Fix trimRetrievedOutput() logic to only clear when all output has been retrieved - Fix race condition by moving buffer cleanup after 'continue' event - Add test coverage for trimRetrievedOutput() edge cases Addresses review comments: - Logic issue in BaseTerminalProcess.trimRetrievedOutput() - Race condition in ExecaTerminalProcess and TerminalProcess - Missing test coverage for buffer trimming
d1fb632 to
cc4ccc5
Compare
|
Hey! I traced through the code and I think there's a timing issue here. The problem is this line: this.lastRetrievedIndex = this.fullOutput.lengthThis marks all output as "retrieved" immediately after the command completes, but What happens:
This breaks the "Inactive Terminals with Completed Process Output" section in The fix would be to not force |
@roomote address this please. |
…rieved output The previous implementation marked all output as 'retrieved' immediately after command completion, before getEnvironmentDetails() had a chance to call getUnretrievedOutput(). This caused hasUnretrievedOutput() to return false, resulting in completed processes being removed from the queue before the AI could see their output. Now trimRetrievedOutput() is called without forcing lastRetrievedIndex, so the buffer is only cleared after output has actually been consumed via getUnretrievedOutput(). Addresses review feedback from daniel-lxs.
Summary