forked from I2P_Developers/i2p.i2p
Summary Bar: Use Rate instead of instantaneous value for used memory
This commit is contained in:
@ -300,9 +300,15 @@ public class SummaryHelper extends HelperBase {
|
|||||||
public String getMemory() {
|
public String getMemory() {
|
||||||
DecimalFormat integerFormatter = new DecimalFormat("###,###,##0");
|
DecimalFormat integerFormatter = new DecimalFormat("###,###,##0");
|
||||||
long tot = SystemVersion.getMaxMemory();
|
long tot = SystemVersion.getMaxMemory();
|
||||||
long free = Runtime.getRuntime().freeMemory();
|
// This reads much higher than the graph, possibly because it's right in
|
||||||
long used = (tot - free) / (1024*1024);
|
// the middle of a console refresh... so get it from the Rate instead.
|
||||||
//long usedPc = 100 - ((free * 100) / tot);
|
//long free = Runtime.getRuntime().freeMemory();
|
||||||
|
long used = (long) _context.statManager().getRate("router.memoryUsed").getRate(60*1000).getAvgOrLifetimeAvg();
|
||||||
|
if (used <= 0) {
|
||||||
|
long free = Runtime.getRuntime().freeMemory();
|
||||||
|
used = tot - free;
|
||||||
|
}
|
||||||
|
used /= 1024*1024;
|
||||||
long total = tot / (1024*1024);
|
long total = tot / (1024*1024);
|
||||||
// long free = Runtime.getRuntime().freeMemory()/1024/1024;
|
// long free = Runtime.getRuntime().freeMemory()/1024/1024;
|
||||||
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
||||||
@ -314,9 +320,19 @@ public class SummaryHelper extends HelperBase {
|
|||||||
public String getMemoryBar() {
|
public String getMemoryBar() {
|
||||||
DecimalFormat integerFormatter = new DecimalFormat("###,###,##0");
|
DecimalFormat integerFormatter = new DecimalFormat("###,###,##0");
|
||||||
long tot = SystemVersion.getMaxMemory();
|
long tot = SystemVersion.getMaxMemory();
|
||||||
long free = Runtime.getRuntime().freeMemory();
|
// This reads much higher than the graph, possibly because it's right in
|
||||||
long used = (tot - free) / (1024*1024);
|
// the middle of a console refresh... so get it from the Rate instead.
|
||||||
long usedPc = 100 - ((free * 100) / tot);
|
//long free = Runtime.getRuntime().freeMemory();
|
||||||
|
long used = (long) _context.statManager().getRate("router.memoryUsed").getRate(60*1000).getAvgOrLifetimeAvg();
|
||||||
|
long usedPc;
|
||||||
|
if (used <= 0) {
|
||||||
|
long free = Runtime.getRuntime().freeMemory();
|
||||||
|
usedPc = 100 - ((free * 100) / tot);
|
||||||
|
used = (tot - free) / (1024*1024);
|
||||||
|
} else {
|
||||||
|
usedPc = used * 100 / tot;
|
||||||
|
used /= 1024*1024;
|
||||||
|
}
|
||||||
long total = tot / (1024*1024);
|
long total = tot / (1024*1024);
|
||||||
// long free = Runtime.getRuntime().freeMemory()/1024/1024;
|
// long free = Runtime.getRuntime().freeMemory()/1024/1024;
|
||||||
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
||||||
|
Reference in New Issue
Block a user