feat: 内存管理可以设置初始大小和最大大小 - #3565
Conversation
审查者指南该 PR 为全局和实例级手动内存分配增加可选的初始堆大小配置,通过共享刻度换算与上限裁剪计算实际值,并在两套 JVM 启动参数路径中生成相应的 -Xms;固定堆和用户自定义 JVM 参数仍保持优先级。 可配置 JVM 初始堆大小的时序图sequenceDiagram
participant User
participant PageSetupLaunch
participant PageInstanceSetup
participant ModLaunch
participant JVM
User->>PageSetupLaunch: Set CustomInitialMemorySize
User->>PageInstanceSetup: Set CustomInitialMemorySize
PageSetupLaunch->>PageSetupLaunch: GetInitialRam
PageInstanceSetup->>PageInstanceSetup: GetInitialRam
ModLaunch->>ModLaunch: SecretLaunchJvmArgs
ModLaunch->>ModLaunch: McLaunchArgumentsJvmOld
alt custom -Xms is configured
ModLaunch->>JVM: Launch with -Xms and -Xmx
else LockMemory is enabled
ModLaunch->>JVM: Launch with -Xms equal to -Xmx
else user supplied -Xms exists
ModLaunch->>JVM: Launch with existing -Xms
end
文件级变更
针对关联 issue 的评估
可能关联的 issue
提示和命令与 Sourcery 交互
自定义使用体验访问你的控制面板,以便:
获取帮助Original review guide in EnglishReviewer's Guide该 PR 为全局和实例级手动内存分配增加可选的初始堆大小配置,通过共享刻度换算与上限裁剪计算实际值,并在两套 JVM 启动参数路径中生成相应的 -Xms;固定堆和用户自定义 JVM 参数仍保持优先级。 Sequence diagram for configurable JVM initial heap sizesequenceDiagram
participant User
participant PageSetupLaunch
participant PageInstanceSetup
participant ModLaunch
participant JVM
User->>PageSetupLaunch: Set CustomInitialMemorySize
User->>PageInstanceSetup: Set CustomInitialMemorySize
PageSetupLaunch->>PageSetupLaunch: GetInitialRam
PageInstanceSetup->>PageInstanceSetup: GetInitialRam
ModLaunch->>ModLaunch: SecretLaunchJvmArgs
ModLaunch->>ModLaunch: McLaunchArgumentsJvmOld
alt custom -Xms is configured
ModLaunch->>JVM: Launch with -Xms and -Xmx
else LockMemory is enabled
ModLaunch->>JVM: Launch with -Xms equal to -Xmx
else user supplied -Xms exists
ModLaunch->>JVM: Launch with existing -Xms
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嘿——我发现了 1 个问题
面向 AI Agent 的提示
请处理本次代码审查中的评论:
## 单独评论
### 评论 1
<location path="Plain Craft Launcher 2/Pages/PageSetup/PageSetupLaunch.xaml.cs" line_range="244-249" />
<code_context>
+ var ramInitial = GetInitialRam(ModInstanceList.McMcInstanceSelected, false);
</code_context>
<issue_to_address>
**issue (broader_impact):** UI 会在分配模式为手动时启用自定义初始内存滑块,但启用固定内存模式(`LockMemory`)后,并不会禁用或重置该控件。在这种状态下,启动器始终输出与 `-Xmx` 相等的 `-Xms`,并忽略配置的初始内存值,因此 UI 允许编辑一个实际上不会生效的设置。
**触发条件:** 手动分配模式和 `LockMemory` 同时启用时。
**建议修复:** 在启用 `LockMemory` 时禁用初始内存控件,并在锁定内存复选框发生变化时刷新该控件的状态。
</issue_to_address>Sourcery 评估
等待批准。 请先处理 1 个发现的问题。
阻塞性发现:Plain Craft Launcher 2/Pages/PageSetup/PageSetupLaunch.xaml.cs:249
请帮助我变得更有用!请在每条评论上点击 👍 或 👎,我会利用这些反馈来改进审查结果。
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="Plain Craft Launcher 2/Pages/PageSetup/PageSetupLaunch.xaml.cs" line_range="244-249" />
<code_context>
+ var ramInitial = GetInitialRam(ModInstanceList.McMcInstanceSelected, false);
</code_context>
<issue_to_address>
**issue (broader_impact):** The UI enables the custom initial-memory slider whenever the allocation mode is manual, but it does not disable or reset that control when fixed-memory mode (`LockMemory`) is enabled. In that state the launcher always emits `-Xms` equal to `-Xmx` and ignores the configured initial-memory value, so the UI permits editing a setting that has no effect.
**Triggers:** When manual allocation mode and `LockMemory` are both enabled.
**Suggested fix:** Disable the initial-memory control while `LockMemory` is enabled, and refresh that state whenever the lock-memory checkbox changes.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: Plain Craft Launcher 2/Pages/PageSetup/PageSetupLaunch.xaml.cs:249
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c4d6ab4ba
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a303e4502f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 64c4db01aa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cdaaf883ac
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // 若 dataList 中已存在 -Xms(例如用户自定义参数已设)则跳过,避免重复/冲突。 | ||
| if (Config.Launch.LockMemory && !dataList.Any(d => d.Contains("-Xms", StringComparison.OrdinalIgnoreCase))) | ||
| dataList.Add("-Xms" + maxHeapArg + "m"); | ||
| if (!dataList.Any(d => d.Contains("-Xms", StringComparison.OrdinalIgnoreCase))) |
There was a problem hiding this comment.
Apply configured Xms over manifest defaults
For instances using the modern arguments.jvm format, McLaunchArgumentsJvmNew populates dataList from the version and inherited JSON before calling this method. If that manifest contains an -Xms default, this guard prevents the newly configured initial-memory value from being added even though HasCustomXms only treats the user's effective custom JVM arguments as an override; the settings UI therefore shows the configured value while launches continue using the manifest value. Distinguish user-supplied overrides from manifest defaults, or replace the manifest's -Xms when applying this setting.
Useful? React with 👍 / 👎.
|
|
|
你不要问我啊,我也不知道 |
Chiloven945
left a comment
There was a problem hiding this comment.
请端正态度。
不要本地化字符串拼接本地化字符串,要么合并要么用分隔符分开。除此之外,zh-CN 请遵守 GB/T 15834-2011,不要在横排文本使用方形引号。
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03ef196774
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| var suffixText = string.Join(", ", | ||
| (ramInitial.HasValue ? Lang.Text("Setup.Launch.Memory.InitialSuffix", Lang.Number(ramInitial.Value, "N1")) : null), | ||
| (ramGame != ramGameActual ? Lang.Text("Setup.Launch.Memory.AvailableSuffix", Lang.Number(ramGameActual, "N1")) : null)); |
There was a problem hiding this comment.
Filter empty memory suffixes before joining
string.Join converts each null element to an empty string but still inserts the separator, so the default case where neither suffix applies produces ", " and renders every memory card as 4.0 GiB (, ); when only one suffix applies, it similarly leaves a leading or trailing comma. Filter out null values before joining (and apply the same correction to the mirrored instance-settings code).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03ef196774
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| var suffixText = string.Join(", ", | ||
| (ramInitial.HasValue ? Lang.Text("Setup.Launch.Memory.InitialSuffix", Lang.Number(ramInitial.Value, "N1")) : null), | ||
| (ramGame != ramGameActual ? Lang.Text("Setup.Launch.Memory.AvailableSuffix", Lang.Number(ramGameActual, "N1")) : null)); |
There was a problem hiding this comment.
Filter absent suffixes before joining
string.Join treats these null elements as empty strings but still emits the separator. Consequently, when neither suffix applies—the normal default with no custom initial heap and sufficient available memory—the label displays GiB (, ); when only one applies, it gets a leading or trailing comma. Filter out null entries before joining, and apply the same correction to the duplicated instance-page formatting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97a529afba
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| <local:MySlider Grid.Row="3" Grid.Column="1" IsEnabled="False" x:Name="SliderRamInitialCustom" | ||
| Tag="LaunchRamCustomInitial" MaxValue="49" Value="0" Change="SliderChange" | ||
| ToolTip="{DynamicResource Setup.Launch.Memory.Initial.ToolTip}" /> |
There was a problem hiding this comment.
Let the initial-memory slider use the RAM-dependent maximum
On systems with more than 48 GiB of RAM, this hard cap prevents configuring -Xms above 48 GiB even though RefreshRam raises the maximum-memory slider beyond tick 49 (for example, tick 57 permits a 64 GiB -Xmx). Update this slider's MaxValue alongside SliderRamCustom.MaxValue, including the mirrored instance slider, so high-memory configurations can select an initial heap up to their configured maximum.
Useful? React with 👍 / 👎.
|
这里都用小写应该就可以了 |
|
原来那个英文就是都用的小写,不过后来我看了一些其他软件,基本上都是用大写的,我也不知道怎么用,要改可以随时改 |
PCL CE en-US 跟随 PCL-Language 非专有名词统一使用 Sentence case。 |




让内存管理可以设置初始大小和最大大小,启动游戏时jvm的Xms和Xmx用自定义设置
Close #3511
除简体中文外其他语言为机器翻译
Sourcery 摘要
允许用户为 Minecraft 启动配置初始和最大 JVM 堆大小。
新功能:
增强功能:
Original summary in English
Sourcery 摘要
支持在现有最大堆内存设置的基础上,配置并应用初始 JVM 堆内存大小。
新功能:
增强功能:
Original summary in English
Sourcery 摘要
支持在现有最大内存设置的基础上,配置并应用自定义初始 JVM 堆大小。
新功能:
增强功能:
-Xms参数,使其优先于自动初始堆配置。Original summary in English
Sourcery 摘要
允许 Minecraft 启动配置设置并应用自定义的 JVM 初始堆大小。
新功能:
增强功能:
-Xms参数,并将自定义初始堆大小限制在已配置的最大值以内。Original summary in English
Sourcery 摘要
支持为 Minecraft 启动配置可自定义的 JVM 初始堆大小,以及最大内存设置。
新功能:
增强功能:
-Xms参数,并将配置的初始堆大小限制为不超过最大堆大小。Original summary in English
Summary by Sourcery
为 Minecraft 启动配置增加可自定义的 JVM 初始堆大小,并将其应用于全局和实例级启动设置。
New Features:
Enhancements:
Original summary in English
Summary by Sourcery
为 Minecraft 启动配置增加可自定义的 JVM 初始堆大小,并将其应用于全局和实例级启动设置。
New Features:
Enhancements: