Skip to content

feat: 新增 HMCLMonitor 子项目,降低启动器隐藏时的内存占用 - #6930

Open
fishdry1000 wants to merge 47 commits into
HMCL-dev:mainfrom
fishdry1000:feature/daemon
Open

fishdry1000 wants to merge 47 commits into
HMCL-dev:mainfrom
fishdry1000:feature/daemon

Conversation

@fishdry1000

@fishdry1000 fishdry1000 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

状态:已完成✅


参见 #4216

Important

当前特性需设置 HMCL_USE_HMCLMONITOR 环境变量启用

离线登录时无法使用自定义皮肤,因为目前没有支持 Yggdrasil 服务器。

新增内容

新 Gradle 子项目 HMCLMonitor

依赖关系:

HMCL -> HMCLMonitor -> HMCLCore
  └───────────────────↗

主项目启动游戏时,将启动参数写入 specFile,然后传递给一个新启动的 HMCL 进程,主进程按照可见性退出。

此时,HMCL 在启动前先进入 Monitor 模式,在该模式下能够:

  • 启动并监视游戏进程状态
  • 在主进程还存活时实时向主进程转发游戏日志
  • 根据设置的启动器可见性,在游戏进程终止后,可选地退出 Monitor 模式,继续启动
  • 如果游戏崩溃,且继续启动,在启动后自动弹出崩溃窗口

流程图(DeepSeek V4.1 Flash & Co Authored By 我):
new (3)

$\color{#996500}{\text{橘色}}$ 线表示进程间通信, $\color{#446E2C}{\text{绿色}}$ 线表示拉起新进程, $\underline{虚}\underline{线}$ 表示原本的启动流程

已修改

HMCLCore: 重构游戏进程视图

新增 ProcessInfo 接口,统一 “本 JVM 直接持有的游戏进程” (ManagedProcess) 与 “monitor 代管的游戏进程” (MonitorGameProcess) 的视图,相关 API 签名从 ManagedProcess 改为 ProcessInfo。

HMCLCore: 提取实用方法

将 UpdateHandler 中 “复用当前 JVM 参数拉起新 java 进程” 的逻辑提取为 JavaProcessLauncher,由 UpdateHandler 与 monitor 共用。

效果

不设置 HMCL_USE_HMCLMONITOR :
image
HMCL 常驻占用 ~400MB

设置 HMCL_USE_HMCLMONITOR :
image
HMCL 常驻占用 ~45MB

启动器可见性:隐藏启动器并在游戏启动后重新打开
显示日志:关
系统:Windows 11 25H2

本机测试 HMCL 内存占用降低 ~85%

@github-actions github-actions Bot added the 1000+ label Oct 1, 2026
@fishdry1000 fishdry1000 changed the title Feature/daemon feat: 新增 HMCLMonitor 子项目,降低启动器隐藏时的内存占用 Oct 1, 2026
@fishdry1000

This comment was marked as outdated.

@fishdry1000

This comment was marked as outdated.

@fishdry1000

This comment was marked as outdated.

@ToobLac

ToobLac commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

不设置 HMCL_USE_HMCLMONITOR : image HMCL 常驻占用 ~400MB

设置 HMCL_USE_HMCLMONITOR : image HMCL 常驻占用 ~45MB

额,能问一下下面这张图为什么多了一个将近 800MB 内存的后台 java 进程吗?

如果这就是 HMCLMonitor 进程的话,那不就是没有任何优化效果吗? 没事了,刚才看错了

@fishdry1000

Copy link
Copy Markdown
Contributor Author

额,能问一下下面这张图为什么多了一个将近 800MB 内存的后台 java 进程吗?

如果这就是 HMCLMonitor 进程的话,那不就是没有任何优化效果吗? 没事了,刚才看错了

这个是构建项目的进程,gradlew run 就会有。你可以看下,两张图都有一个 ~800M 的 java 进程。至于为什么一会后台一会前台我就不是很清楚了

@fishdry1000
fishdry1000 marked this pull request as draft October 11, 2026 13:35
@fishdry1000

This comment was marked as outdated.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCLMonitor/src/main/java/org/jackhuang/hmcl/monitor/MonitorClient.java Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCLMonitor/src/main/java/org/jackhuang/hmcl/monitor/MonitorLauncher.java Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCLMonitor/src/main/java/org/jackhuang/hmcl/monitor/MonitorLauncher.java Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCLMonitor/src/main/java/org/jackhuang/hmcl/monitor/MonitorLauncher.java Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCLMonitor/src/main/java/org/jackhuang/hmcl/monitor/MonitorLauncher.java Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCLMonitor/src/main/java/org/jackhuang/hmcl/monitor/MonitorGameProcess.java Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCLMonitor/src/main/java/org/jackhuang/hmcl/monitor/MonitorGameProcess.java Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCLMonitor/src/main/java/org/jackhuang/hmcl/monitor/MonitorGameProcess.java Outdated
@fishdry1000
fishdry1000 marked this pull request as ready for review October 23, 2026 14:09

This branch has not been deployed

No deployments
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