Skip to content

修复游戏日志过多导致日志窗口 OOM 的问题 - #6668

Open
Hylfrd wants to merge 2 commits into
HMCL-dev:mainfrom
Hylfrd:fix/game-log-window-performance
Open

修复游戏日志过多导致日志窗口 OOM 的问题#6668
Hylfrd wants to merge 2 commits into
HMCL-dev:mainfrom
Hylfrd:fix/game-log-window-performance

Conversation

@Hylfrd

@Hylfrd Hylfrd commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

#5685 中 burningtnt 提到,HMCL 会将 200ms 内收到的游戏日志聚合后一次性提交到日志窗口。当游戏短时间内输出大量日志时,待上屏日志会在无界队列中持续积压,并形成过大的上屏批次,导致 HMCL 内存占用过高、界面无响应甚至 OOM。

此 PR 根据日志窗口配置的显示行数限制待上屏日志数量。缓冲区达到上限时,丢弃尚未显示的最旧日志并保留最新日志,避免待上屏队列和单次上屏批次无限增长。

注:#6667 修复的问题也会在相同场景下独立导致 OOM。建议两个 PR 一并合并;若仅合并此 PR,尽管日志窗口的队列不再无限积压,但 ManagedProcess 仍会保存全部游戏输出,大量日志下 HMCL 仍可能发生 OOM。

@github-actions github-actions Bot added the 10+ label Aug 12, 2026
@Glavo

Glavo commented Aug 12, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 2f22d60420

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

private Thread submitLogThread;
private LinkedBlockingQueue<Log> logBuffer;
/// Pending logs for the log window.
private final BlockingDeque<Log> logBuffer = new LinkedBlockingDeque<>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你不都改成加锁了吗?为什么还要用 LinkedBlockingDeque

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants