fixed not getting the correct allocated memory

This commit is contained in:
2024-10-05 20:41:19 +02:00
parent f4c4842188
commit 0e270085f9
4 changed files with 8 additions and 6 deletions

View File

@@ -34,7 +34,8 @@ public class LoadSupport
{
AutoConfig.register(LSConfig.class, Toml4jConfigSerializer::new);
config = AutoConfig.getConfigHolder(LSConfig.class).getConfig();
allocatedMemoryInGB = Runtime.getRuntime().totalMemory() / 1073741824f; // Hardcoded value for GB
allocatedMemoryInGB = Runtime.getRuntime().maxMemory() / 1073741824f; // Hardcoded value for GB
allocatedMemoryInGB = Math.round(allocatedMemoryInGB * 10) / 10f;
LoadSupport.logger.info(String.format("Allocated Memory: %.1f GB", allocatedMemoryInGB));
ScreenEvents.BEFORE_INIT.register(LoadSupport::beforeWindowInit);
}
@@ -52,6 +53,6 @@ public class LoadSupport
public static String[] getWarningMessage(){
return new String[]{config.errorTitle, config.errorDescription
.replace("{minMemory}", String.valueOf(config.minMemory))
.replace("{currentMemory}", String.format("%.1f", allocatedMemoryInGB))};
.replace("{currentMemory}", String.valueOf(allocatedMemoryInGB))};
};
}