summaryrefslogtreecommitdiff
path: root/NET/worlds/console/StatMemNode.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/StatMemNode.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/StatMemNode.java')
-rw-r--r--NET/worlds/console/StatMemNode.java105
1 files changed, 105 insertions, 0 deletions
diff --git a/NET/worlds/console/StatMemNode.java b/NET/worlds/console/StatMemNode.java
new file mode 100644
index 0000000..1e3fc21
--- /dev/null
+++ b/NET/worlds/console/StatMemNode.java
@@ -0,0 +1,105 @@
+package NET.worlds.console;
+
+import NET.worlds.core.Std;
+import java.awt.List;
+
+public class StatMemNode extends StatMan implements MainCallback {
+ private static StatMemNode _singleInstance = new StatMemNode();
+ private int _lastTime;
+ private static final int TITLE = 0;
+ private static final int BLANK1 = 1;
+ private static final int TOTMEM = 2;
+ private static final int FREEMEM = 3;
+ private static final int BLANK2 = 4;
+ private static final int TOTPHYSMEM = 5;
+ private static final int AVAILPHYSMEM = 6;
+ private static final int SWAPUSED = 7;
+ private static final int AVAILVIRTMEM = 8;
+ private static final int TOTUSED = 9;
+ private long _lastTotMem;
+ public int _totPhysMem;
+ public int _availPhysMem;
+ public int _totPageMem;
+ public int _availPageMem;
+
+ static {
+ nativeInit();
+ }
+
+ public static StatMemNode getNode() {
+ return _singleInstance;
+ }
+
+ private StatMemNode() {
+ StatisticsRoot.getNode().addChild(this);
+ }
+
+ public static native void nativeInit();
+
+ @Override
+ public String toString() {
+ return "System Memory";
+ }
+
+ @Override
+ synchronized void grabList(List list) {
+ super.grabList(list);
+ Main.register(this);
+ }
+
+ @Override
+ synchronized void releaseList(boolean terminalCallback) {
+ if (!terminalCallback) {
+ Main.unregister(this);
+ }
+
+ super.releaseList(terminalCallback);
+ }
+
+ @Override
+ public synchronized void mainCallback() {
+ int thisTime = Std.getFastTime();
+ if (thisTime - this._lastTime > 1000) {
+ this.updateList();
+ this._lastTime = thisTime;
+ }
+ }
+
+ public int getVMAvail() {
+ this.updateMemoryStatus();
+ return this._availPageMem;
+ }
+
+ @Override
+ void createList() {
+ this._grabbedList.add("System Memory Stats", 0);
+ this._grabbedList.add("", 1);
+ this._lastTotMem = Runtime.getRuntime().totalMemory();
+ this._grabbedList.add("Total " + Std.getProductName() + " Memory Available: " + this._lastTotMem + " bytes", 2);
+ this.updateMemoryStatus();
+ this._grabbedList.add(" Free " + Std.getProductName() + " Memory Available: " + Runtime.getRuntime().freeMemory() + " bytes", 3);
+ this._grabbedList.add("", 4);
+ this._grabbedList.add("Total System Physical Memory: " + this._totPhysMem + " bytes", 5);
+ this._grabbedList.add("Available System Physical Memory: " + this._availPhysMem + " bytes", 6);
+ this._grabbedList.add("Total System Swapfile Usage: " + (this._totPageMem - this._availPageMem) + " bytes", 7);
+ this._grabbedList.add("Available Virtual Memory: " + this._availPageMem + " bytes", 8);
+ }
+
+ @Override
+ void updateList() {
+ long thisTotMem = Runtime.getRuntime().totalMemory();
+ if (thisTotMem != this._lastTotMem) {
+ this._lastTotMem = thisTotMem;
+ this._grabbedList.replaceItem("Total " + Std.getProductName() + " Memory Available: " + this._lastTotMem + " bytes", 2);
+ }
+
+ this.updateMemoryStatus();
+ this._grabbedList.replaceItem(" Free " + Std.getProductName() + " Memory Available: " + Runtime.getRuntime().freeMemory() + " bytes", 3);
+ this._grabbedList.replaceItem("Total System Physical Memory: " + this._totPhysMem + " bytes", 5);
+ this._grabbedList.replaceItem("Available System Physical Memory: " + this._availPhysMem + " bytes", 6);
+ this._grabbedList.replaceItem("Total System Swapfile Usage: " + (this._totPageMem - this._availPageMem) + " bytes", 7);
+ this._grabbedList.replaceItem("Available Virtual Memory: " + this._availPageMem + " bytes", 8);
+ }
+
+ public native void updateMemoryStatus();
+}