1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
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 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 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()));
}
}
|