summaryrefslogtreecommitdiff
path: root/NET/worlds/console/StatMemNode.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-13 02:24:08 -0800
committerFuwn <[email protected]>2026-02-13 04:13:49 -0800
commit0d6fb4c116fefb36cbd60a7f17d280cf899c43fb (patch)
treef3c3c7be5dbb2685a60a0b35a4e59e771b3f1a24 /NET/worlds/console/StatMemNode.java
parentfeat: Reimplement core I/O and system information native methods with pure Java (diff)
downloadworldsplayer-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/console/StatMemNode.java')
-rw-r--r--NET/worlds/console/StatMemNode.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/NET/worlds/console/StatMemNode.java b/NET/worlds/console/StatMemNode.java
index b5031dd..903bf0d 100644
--- a/NET/worlds/console/StatMemNode.java
+++ b/NET/worlds/console/StatMemNode.java
@@ -5,6 +5,8 @@ import java.awt.List;
public class StatMemNode extends StatMan implements MainCallback {
private static StatMemNode _singleInstance = new StatMemNode();
+ private static final com.sun.management.OperatingSystemMXBean operatingSystemMXBean =
+ (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();
private int _lastTime;
private static final int TITLE = 0;
private static final int BLANK1 = 1;
@@ -103,11 +105,9 @@ public class StatMemNode extends StatMan implements MainCallback {
}
public void updateMemoryStatus() {
- Runtime runtime = Runtime.getRuntime();
-
- this._totPhysMem = (int)runtime.maxMemory();
- this._availPhysMem = (int)runtime.freeMemory();
- this._totPageMem = (int)runtime.totalMemory();
- this._availPageMem = (int)(runtime.maxMemory() - (runtime.totalMemory() - runtime.freeMemory()));
+ this._totPhysMem = (int)operatingSystemMXBean.getTotalPhysicalMemorySize();
+ this._availPhysMem = (int)operatingSystemMXBean.getFreePhysicalMemorySize();
+ this._totPageMem = (int)operatingSystemMXBean.getTotalSwapSpaceSize();
+ this._availPageMem = (int)operatingSystemMXBean.getFreeSwapSpaceSize();
}
}