Skip to content

Commit

Permalink
Add MemoryProbe for testing and debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Feb 2, 2016
1 parent eb3895a commit 4210c12
Showing 1 changed file with 9 additions and 9 deletions.
Expand Up @@ -4,11 +4,11 @@
* *
* @author Per Minborg * @author Per Minborg
*/ */
public class MemorySnapshot { public class MemoryProbe {


private final long free, total, max; private final long free, total, max;


private MemorySnapshot() { private MemoryProbe() {
System.gc(); System.gc();
System.gc(); System.gc();
final Runtime rt = Runtime.getRuntime(); final Runtime rt = Runtime.getRuntime();
Expand All @@ -17,7 +17,7 @@ private MemorySnapshot() {
this.max = rt.maxMemory(); this.max = rt.maxMemory();
} }


protected MemorySnapshot(long free, long total, long max) { protected MemoryProbe(long free, long total, long max) {
this.free = free; this.free = free;
this.total = total; this.total = total;
this.max = max; this.max = max;
Expand Down Expand Up @@ -50,16 +50,16 @@ public String toString() {
} }




public MemorySnapshot deltaSinceCreated() { public MemoryProbe deltaSinceCreated() {
return substract(new MemorySnapshot()); return substract(new MemoryProbe());
} }


public static MemorySnapshot create() { public static MemoryProbe create() {
return new MemorySnapshot(); return new MemoryProbe();
} }


public MemorySnapshot substract(MemorySnapshot operand) { public MemoryProbe substract(MemoryProbe operand) {
return new MemorySnapshot(free() - operand.free(), total() - operand.total(), max() - operand.max()); return new MemoryProbe(free() - operand.free(), total() - operand.total(), max() - operand.max());
} }


} }

0 comments on commit 4210c12

Please sign in to comment.