Tweak(jvm arg): take control of -XX:ActiveProcessorCount

Setting it ourselves guarantee a better experience by default
This commit is contained in:
Mathias-Boulay
2024-12-20 22:35:13 +01:00
parent b57a0cdab7
commit 3feb6927c9
2 changed files with 6 additions and 1 deletions

View File

@@ -155,7 +155,7 @@ public class LauncherPreferences {
/// Find a correct resolution for the device
///
/// Some devices are shipped with ridiculously high resolution, which can cause performance issues
/// Some devices are shipped with a ridiculously high resolution, which can cause performance issues
/// This function will try to find a resolution that is good enough for the device
private static int findBestResolution(Context context, boolean isDevicePowerful) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();

View File

@@ -295,6 +295,8 @@ public class JREUtils {
purgeArg(userArgs, "-Dorg.lwjgl.opengl.libname");
// Don't let the user specify a custom Freetype library (as the user is unlikely to specify a version compiled for Android)
purgeArg(userArgs, "-Dorg.lwjgl.freetype.libname");
// Overridden by us to specify the exact number of cores that the android system has
purgeArg(userArgs, "-XX:ActiveProcessorCount");
//Add automatically generated args
userArgs.add("-Xms" + LauncherPreferences.PREF_RAM_ALLOCATION + "M");
@@ -305,6 +307,9 @@ public class JREUtils {
// that we ship with Java (since it may be older than what's needed)
userArgs.add("-Dorg.lwjgl.freetype.libname="+ NATIVE_LIB_DIR+"/libfreetype.so");
// Some phones are not using the right number of cores, fix that
userArgs.add("-XX:ActiveProcessorCount=" + java.lang.Runtime.getRuntime().availableProcessors());
userArgs.addAll(JVMArgs);
activity.runOnUiThread(() -> Toast.makeText(activity, activity.getString(R.string.autoram_info_msg,LauncherPreferences.PREF_RAM_ALLOCATION), Toast.LENGTH_SHORT).show());
System.out.println(JVMArgs);