[FEATURE] getJVMTotalMemory

This commit is contained in:
Gravit 2019-02-17 18:27:44 +07:00
parent 44a4feacde
commit 517ffbd371
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 21 additions and 2 deletions

View file

@ -29,9 +29,9 @@ var settingsClass = Java.extend(LauncherSettingsClass.static, {
setRAM: function(ram) { setRAM: function(ram) {
if (ram>762&&ram<1024){ if (ram>762&&ram<1024){
settings.ram = java.lang.Math["min(int,int)"](ram, FunctionalBridge.getTotalMemory()); settings.ram = java.lang.Math["min(int,int)"](ram, FunctionalBridge.getJVMTotalMemory());
}else{ }else{
settings.ram = java.lang.Math["min(int,int)"](((ram / 256) | 0) * 256, FunctionalBridge.getTotalMemory()); settings.ram = java.lang.Math["min(int,int)"](((ram / 256) | 0) * 256, FunctionalBridge.getJVMTotalMemory());
} }
}, },
}); });

View file

@ -3,6 +3,7 @@
import javafx.concurrent.Task; import javafx.concurrent.Task;
import ru.gravit.launcher.HWID; import ru.gravit.launcher.HWID;
import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherAPI;
import ru.gravit.launcher.guard.LauncherGuardManager;
import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.FileNameMatcher;
import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedDir;
import ru.gravit.launcher.hwid.OshiHWIDProvider; import ru.gravit.launcher.hwid.OshiHWIDProvider;
@ -79,6 +80,24 @@ public static long getTotalMemory() {
return hwidProvider.getTotalMemory() >> 20; return hwidProvider.getTotalMemory() >> 20;
} }
@LauncherAPI
public static int getClientJVMBits()
{
return LauncherGuardManager.guard.getClientJVMBits();
}
@LauncherAPI
public static long getJVMTotalMemory()
{
if(getClientJVMBits() == 32)
{
return Math.min(getTotalMemory(),1536);
}
else
{
return getTotalMemory();
}
}
@LauncherAPI @LauncherAPI
public static HasherStore getDefaultHasherStore() { public static HasherStore getDefaultHasherStore() {
return HasherManager.getDefaultStore(); return HasherManager.getDefaultStore();