diff options
| author | Fuwn <[email protected]> | 2026-02-13 02:24:08 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-13 04:13:49 -0800 |
| commit | 0d6fb4c116fefb36cbd60a7f17d280cf899c43fb (patch) | |
| tree | f3c3c7be5dbb2685a60a0b35a4e59e771b3f1a24 /NET/worlds/core/SystemInfo.java | |
| parent | feat: Reimplement core I/O and system information native methods with pure Java (diff) | |
| download | worldsplayer-0d6fb4c116fefb36cbd60a7f17d280cf899c43fb.tar.xz worldsplayer-0d6fb4c116fefb36cbd60a7f17d280cf899c43fb.zip | |
fix: Use real system memory via OperatingSystemMXBean
Replaces JVM Runtime heap values with actual system physical/swap
memory from com.sun.management.OperatingSystemMXBean, matching
the Win32 GlobalMemoryStatus values the originals returned.
Diffstat (limited to 'NET/worlds/core/SystemInfo.java')
| -rw-r--r-- | NET/worlds/core/SystemInfo.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/NET/worlds/core/SystemInfo.java b/NET/worlds/core/SystemInfo.java index 8a138aa..594c88d 100644 --- a/NET/worlds/core/SystemInfo.java +++ b/NET/worlds/core/SystemInfo.java @@ -7,6 +7,8 @@ import java.io.PrintStream; public class SystemInfo implements MainCallback, MainTerminalCallback { private static SystemInfo instance = new SystemInfo(); + private static final com.sun.management.OperatingSystemMXBean operatingSystemMXBean = + (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean(); private long _lastFrame = 0L; private long _lastReport = 0L; private long _min; @@ -111,22 +113,19 @@ public class SystemInfo implements MainCallback, MainTerminalCallback { } public static int GetTotalPhysicalMemory() { - return (int)(Runtime.getRuntime().maxMemory() / 1024L); + return (int)(operatingSystemMXBean.getTotalPhysicalMemorySize() / 1024L); } public static int GetAvailPhysicalMemory() { - return (int)(Runtime.getRuntime().freeMemory() / 1024L); + return (int)(operatingSystemMXBean.getFreePhysicalMemorySize() / 1024L); } public static int GetTotalPagedMemory() { - return (int)(Runtime.getRuntime().totalMemory() / 1024L); + return (int)(operatingSystemMXBean.getTotalSwapSpaceSize() / 1024L); } public static int GetAvailPagedMemory() { - Runtime runtime = Runtime.getRuntime(); - long availableMemory = runtime.maxMemory() - (runtime.totalMemory() - runtime.freeMemory()); - - return (int)(availableMemory / 1024L); + return (int)(operatingSystemMXBean.getFreeSwapSpaceSize() / 1024L); } public static String GetPlatformID() { |