修复游戏日志过多导致启动器内存占用过高的问题 - #6667
Closed
Hylfrd wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
进一步检查和复现后确认,@burningtnt 在 #5685 提到的 200ms 日志聚合上屏并不是 #5685 所述问题的直接原因。该逻辑只在开启游戏日志窗口时运行,而 #5685 在未打开日志窗口的情况下仍可复现。 本 PR 修复的实际问题是:HMCL 会在 ManagedProcess 中保存游戏进程的全部输出,仅用于游戏退出后的状态判断。大量日志会因此导致启动器内存占用持续增长。 不过,200ms 聚合上屏的实现确实会在短时间日志量过大时引发独立的性能问题。该问题将另开一个 PR 处理。 |
Member
|
不应该对于每条日志都执行繁重的操作,我们需要 onLog 尽可能简单快速。 |
Contributor
Author
|
我思考一下能否有更好的实现 |
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.
Fixed #5685 #6640
游戏运行过程中,HMCL 会将游戏的全部标准输出和错误输出保存在
ManagedProcess中,用于游戏退出时判断 JVM 启动失败或异常退出。即使没有打开日志窗口,该缓存仍会随日志量持续增长;日志过多时会导致启动器内存占用过高,并可能发生 OOM。此 PR 改为在接收日志时直接记录退出判断所需的错误标志,不再保存完整的游戏输出。游戏退出类型的判断行为保持不变。
使用测试模组输出约 608 MiB 日志,HMCL 分配 256 MiB 堆内存。修改前,HMCL 堆占用增长至约 255 MiB,发生 OOM 并最终发生 JVM 崩溃;修改后,游戏正常进入主菜单,HMCL 堆占用稳定在约 77 MiB。
注:部分注释由AI完成。