修复游戏日志过多导致日志窗口 OOM 的问题 - #6668
Open
Hylfrd wants to merge 2 commits into
Open
Conversation
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Glavo
reviewed
Aug 12, 2026
| private Thread submitLogThread; | ||
| private LinkedBlockingQueue<Log> logBuffer; | ||
| /// Pending logs for the log window. | ||
| private final BlockingDeque<Log> logBuffer = new LinkedBlockingDeque<>(); |
Member
There was a problem hiding this comment.
你不都改成加锁了吗?为什么还要用 LinkedBlockingDeque?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#5685 中 burningtnt 提到,HMCL 会将 200ms 内收到的游戏日志聚合后一次性提交到日志窗口。当游戏短时间内输出大量日志时,待上屏日志会在无界队列中持续积压,并形成过大的上屏批次,导致 HMCL 内存占用过高、界面无响应甚至 OOM。
此 PR 根据日志窗口配置的显示行数限制待上屏日志数量。缓冲区达到上限时,丢弃尚未显示的最旧日志并保留最新日志,避免待上屏队列和单次上屏批次无限增长。
注:#6667 修复的问题也会在相同场景下独立导致 OOM。建议两个 PR 一并合并;若仅合并此 PR,尽管日志窗口的队列不再无限积压,但
ManagedProcess仍会保存全部游戏输出,大量日志下 HMCL 仍可能发生 OOM。