comparison src/org/dancres/blitz/stats/MemoryStat.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
1 package org.dancres.blitz.stats;
2
3 /**
4 <p>Tracks memory usage statistics. This stat is permanently enabled and
5 cannot be switched on or off. It's maintenance costs are entirely absorbed
6 by the caller recovering stats from StatsBoard.</p>
7 */
8 public class MemoryStat implements Stat, StatGenerator {
9 private long theId = StatGenerator.UNSET_ID;
10
11 private long theMaxMemory;
12 private long theCurrentMemory;
13
14 MemoryStat() {
15 }
16
17 MemoryStat(long anId, long aMaxMem, long aCurrentMem) {
18 theId = anId;
19 theMaxMemory = aMaxMem;
20 theCurrentMemory = aCurrentMem;
21 }
22
23 public void setId(long anId) {
24 theId = anId;
25 }
26
27 public long getId() {
28 return theId;
29 }
30
31 public synchronized Stat generate() {
32 MemoryStat myStat = new MemoryStat(theId,
33 Runtime.getRuntime().maxMemory(),
34 Runtime.getRuntime().totalMemory());
35 return myStat;
36 }
37
38 public long getMaxMemory() {
39 return theMaxMemory;
40 }
41
42 public long getCurrentMemory() {
43 return theCurrentMemory;
44 }
45
46 public String toString() {
47 return "Memory: " + theCurrentMemory + " of: " + theMaxMemory;
48 }
49 }