-
Notifications
You must be signed in to change notification settings - Fork 143
feat: 内存管理可以设置初始大小和最大大小 #3565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat: 内存管理可以设置初始大小和最大大小 #3565
Changes from 5 commits
3c4d6ab
a303e45
64c4db0
cdaaf88
03ef196
97a529a
1e98a53
a8548cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2135,10 +2135,22 @@ internal static void SecretLaunchJvmArgs(ref List<string> dataList) | |
| var maxHeapArg = Math.Floor(totalRamMb).ToString(CultureInfo.InvariantCulture); | ||
| dataList.Add("-Xmn" + Math.Floor(totalRamMb * 0.15).ToString(CultureInfo.InvariantCulture) + "m"); | ||
| dataList.Add("-Xmx" + maxHeapArg + "m"); | ||
| // #3282: 固定堆大小时追加 -Xms 使其等于 -Xmx(复用同一数值以保持一致),隐式禁用内存归还降低延迟抖动、利于 ZGC。 | ||
| // 若 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For instances using the modern Useful? React with 👍 / 👎. |
||
| { | ||
| if (Config.Launch.LockMemory) | ||
| { | ||
| // #3282: 固定堆大小时追加 -Xms 使其等于 -Xmx(复用同一数值以保持一致),隐式禁用内存归还降低延迟抖动、利于 ZGC。 | ||
| dataList.Add("-Xms" + maxHeapArg + "m"); | ||
| } | ||
| else | ||
| { | ||
| // #3511: 支持自定义初始堆大小(-Xms),可低于最大堆。 | ||
| var initialRam = PageInstanceSetup.GetInitialRam(ModInstanceList.McMcInstanceSelected); | ||
| if (initialRam.HasValue) | ||
| dataList.Add("-Xms" + Math.Floor(initialRam.Value * 1024d).ToString(CultureInfo.InvariantCulture) + "m"); | ||
| } | ||
| } | ||
| if (!dataList.Any(d => d.Contains("-Dlog4j2.formatMsgNoLookups=true"))) | ||
| dataList.Add("-Dlog4j2.formatMsgNoLookups=true"); | ||
| } | ||
|
|
@@ -2467,10 +2479,23 @@ private static string McLaunchArgumentsJvmOld(McInstance instance) | |
| var maxHeapArg = Math.Floor(PageInstanceSetup.GetRam(ModInstanceList.McMcInstanceSelected, | ||
| !mcLaunchJavaSelected.Installation.Is64Bit) * 1024d); | ||
| dataList.Add("-Xmx" + maxHeapArg + "m"); | ||
| // #3282: 固定堆大小时追加 -Xms 使其等于 -Xmx(复用同一数值以保持一致),隐式禁用内存归还降低延迟抖动、利于 ZGC。 | ||
| // 若 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))) | ||
| { | ||
| if (Config.Launch.LockMemory) | ||
| { | ||
| // #3282: 固定堆大小时追加 -Xms 使其等于 -Xmx(复用同一数值以保持一致),隐式禁用内存归还降低延迟抖动、利于 ZGC。 | ||
| dataList.Add("-Xms" + maxHeapArg + "m"); | ||
| } | ||
| else | ||
| { | ||
| // #3511: 支持自定义初始堆大小(-Xms),可低于最大堆。 | ||
| var initialRam = PageInstanceSetup.GetInitialRam(ModInstanceList.McMcInstanceSelected, | ||
| !mcLaunchJavaSelected.Installation.Is64Bit); | ||
| if (initialRam.HasValue) | ||
| dataList.Add("-Xms" + Math.Floor(initialRam.Value * 1024d).ToString(CultureInfo.InvariantCulture) + "m"); | ||
| } | ||
| } | ||
| dataList.Add("\"-Djava.library.path=" + GetNativesFolder() + "\""); | ||
| dataList.Add("-cp ${classpath}"); // 把支持库添加进启动参数表 | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.