fix(ModLaunch): 修复使用JAVA7及更早版本时,未设置永久代内存导致游戏频繁内存溢出崩溃的问题#2637
fix(ModLaunch): 修复使用JAVA7及更早版本时,未设置永久代内存导致游戏频繁内存溢出崩溃的问题#2637MegaWall3 wants to merge 1 commit intoPCL-Community:devfrom
Conversation
审阅者指南(在小型 PR 上折叠)审阅者指南在使用 Java 7 或更早版本启动 Minecraft 时自动添加 PermGen JVM 选项,以防止 PermGen 空间 OutOfMemory 错误,同时尊重用户已指定的 PermGen 设置并记录相关行为。 带条件 PermGen 选项的 Minecraft 启动时序图sequenceDiagram
actor User
participant Launcher
participant JavaInstallation
participant JVM
User->>Launcher: StartMinecraftInstance()
Launcher->>JavaInstallation: Get MajorVersion
JavaInstallation-->>Launcher: MajorVersion
Launcher->>Launcher: Initialize DataList with base JVM args
alt MajorVersion <= 7
Launcher->>Launcher: Check DataList for PermSize or MaxPermSize
alt No existing PermGen options
Launcher->>Launcher: DataList.Add -XX:PermSize=128m
Launcher->>Launcher: DataList.Add -XX:MaxPermSize=256m
Launcher->>Launcher: McLaunchLog auto added PermGen options
else User already set PermGen options
Launcher->>Launcher: McLaunchLog skip auto add
end
else MajorVersion > 7
Launcher->>Launcher: Do not modify PermGen options
end
Launcher->>Launcher: Add -Djava.library.path
Launcher->>Launcher: Add -cp ${classpath}
Launcher->>JVM: Launch with DataList arguments
JVM-->>User: Run Minecraft instance
文件级变更
技巧与命令与 Sourcery 交互
自定义你的体验访问你的 仪表盘 来:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideAdds automatic PermGen JVM options when launching Minecraft with Java 7 or earlier to prevent PermGen space OutOfMemory errors, while respecting any user-specified PermGen settings and logging the behavior. Sequence diagram for Minecraft launch with conditional PermGen optionssequenceDiagram
actor User
participant Launcher
participant JavaInstallation
participant JVM
User->>Launcher: StartMinecraftInstance()
Launcher->>JavaInstallation: Get MajorVersion
JavaInstallation-->>Launcher: MajorVersion
Launcher->>Launcher: Initialize DataList with base JVM args
alt MajorVersion <= 7
Launcher->>Launcher: Check DataList for PermSize or MaxPermSize
alt No existing PermGen options
Launcher->>Launcher: DataList.Add -XX:PermSize=128m
Launcher->>Launcher: DataList.Add -XX:MaxPermSize=256m
Launcher->>Launcher: McLaunchLog auto added PermGen options
else User already set PermGen options
Launcher->>Launcher: McLaunchLog skip auto add
end
else MajorVersion > 7
Launcher->>Launcher: Do not modify PermGen options
end
Launcher->>Launcher: Add -Djava.library.path
Launcher->>Launcher: Add -cp ${classpath}
Launcher->>JVM: Launch with DataList arguments
JVM-->>User: Run Minecraft instance
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出了一些总体反馈:
- 硬编码的
-XX:PermSize=128m和-XX:MaxPermSize=256m配置可能不适用于所有内存设置;建议根据所选 RAM 进行推导(类似于-Xmx/-Xmn),或者将这些值集中为可配置常量。 - 当前检测已有 PermGen 选项的方式是对完整参数字符串使用
Contains,在某些边缘场景下可能会产生误报;建议更严格地匹配参数键(例如使用相等判断,或检查-XX:PermSize=/-XX:MaxPermSize=前缀)。
供 AI 代理使用的提示词
Please address the comments from this code review:
## Overall Comments
- The hardcoded `-XX:PermSize=128m` and `-XX:MaxPermSize=256m` values might not suit all memory configurations; consider deriving them from the selected RAM (similar to `-Xmx`/`-Xmn`) or centralizing them as configurable constants.
- The detection of existing PermGen options uses `Contains` on the full argument string, which could give false positives in edge cases; consider matching the argument key more strictly (e.g., equality or prefix check with `-XX:PermSize=` / `-XX:MaxPermSize=`).帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- The hardcoded
-XX:PermSize=128mand-XX:MaxPermSize=256mvalues might not suit all memory configurations; consider deriving them from the selected RAM (similar to-Xmx/-Xmn) or centralizing them as configurable constants. - The detection of existing PermGen options uses
Containson the full argument string, which could give false positives in edge cases; consider matching the argument key more strictly (e.g., equality or prefix check with-XX:PermSize=/-XX:MaxPermSize=).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The hardcoded `-XX:PermSize=128m` and `-XX:MaxPermSize=256m` values might not suit all memory configurations; consider deriving them from the selected RAM (similar to `-Xmx`/`-Xmn`) or centralizing them as configurable constants.
- The detection of existing PermGen options uses `Contains` on the full argument string, which could give false positives in edge cases; consider matching the argument key more strictly (e.g., equality or prefix check with `-XX:PermSize=` / `-XX:MaxPermSize=`).Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
MoYuan-CN
left a comment
There was a problem hiding this comment.
参考上方 Sourcery Review 内容
另外,你需要对 Git 提交进行签名,请参考 GPG Key 完全配置指南,并对已有的提交重新签名后 Force-Push 到你的分支
|
AI审查水平不佳 未遵循KISS原则 过度设计不符合工程实践 1.永久代内存主要存储类元数据,分配多少取决于扩展多少Mod,与总分配内存无关,且128M相比JAVA7硬编码值扩大一倍,最大256M存在扩展性,完全合理。 2.JVM参数大小写敏感,且无相似易混淆的其他参数,边缘场景不存在,无实际意义。 另外,此代码由 Claude 高阶模型生成,建议 Reviewer 关注业务逻辑本身,而非盲从免费 AI 生成的泛化建议。 |
LinQingYuu
left a comment
There was a problem hiding this comment.
请使用 SSH 或 GPG Key 对提交进行签名,并确保在 GitHub 账户上添加了对应公钥
|
|
欢迎修复上述问题之后再次发起 PR,但十分不建议尝试使用 AI 添加配置项等相关更改 |
Java 7 及更早版本使用永久代 (PermGen) 存储类元数据,其大小固定(默认约64-128MB),而往后的 Java 8 用元空间 (Metaspace) 替代了 PermGen,可自动扩展。
在使用Java7游玩1.6.4老版本怀旧时,频繁出现"java.lang.OutOfMemoryError: PermGen space"错误致客户端崩溃。
该PR永久修复了此问题,当检测到用户选择了老版本Java时,如果用户未指定这个参数,自动添加了PermGen参数,扩充预分配的内存额度。
在官方版提交完发现这里也有这个问题=v=
Summary by Sourcery
在使用旧版 Java 启动 Minecraft 实例时,确保正确配置 JVM 内存设置,以防止与 PermGen 相关的崩溃。
Bug 修复:
OutOfMemoryError: PermGen space。增强功能:
Original summary in English
Summary by Sourcery
Ensure proper JVM memory configuration when launching Minecraft instances with older Java versions to prevent PermGen-related crashes.
Bug Fixes:
Enhancements: