bb.util
Class MemoryMeasurer.UnitTest.MemoryFiller

java.lang.Object
  extended by bb.util.MemoryMeasurer.UnitTest.MemoryFiller
Enclosing class:
MemoryMeasurer.UnitTest

public static class MemoryMeasurer.UnitTest.MemoryFiller
extends Object

Class which attempts to fill up memory to a specified point. Is public so that other classes may access.


Field Summary
private  double fillPoint
           
private  long interval
           
private static long interval_default
           
private  MemoryMeasurer measurer
           
private static int numObjsCreatedPerLoop
           
private  List<Object> objects
           
 
Constructor Summary
MemoryMeasurer.UnitTest.MemoryFiller(double fillPoint, long interval, MemoryMeasurer measurer)
          Fundamental constructor.
MemoryMeasurer.UnitTest.MemoryFiller(double fillPoint, MemoryMeasurer measurer)
          Returns this(fillPoint, interval_default, measurer).
 
Method Summary
 void fill()
          Executes a loop which fills up the memory.
 void free()
          Removes references to all the objects created by fill so that they can be garbage collected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

interval_default

private static final long interval_default
See Also:
Constant Field Values

numObjsCreatedPerLoop

private static final int numObjsCreatedPerLoop
See Also:
Constant Field Values

fillPoint

private final double fillPoint

interval

private final long interval

measurer

private final MemoryMeasurer measurer

objects

private final List<Object> objects
Constructor Detail

MemoryMeasurer.UnitTest.MemoryFiller

public MemoryMeasurer.UnitTest.MemoryFiller(double fillPoint,
                                            MemoryMeasurer measurer)
                                     throws IllegalArgumentException
Returns this(fillPoint, interval_default, measurer).

Throws:
IllegalArgumentException

MemoryMeasurer.UnitTest.MemoryFiller

public MemoryMeasurer.UnitTest.MemoryFiller(double fillPoint,
                                            long interval,
                                            MemoryMeasurer measurer)
                                     throws IllegalArgumentException
Fundamental constructor.

Throws:
IllegalArgumentException - if fillPoint <= 0; fillPoint >= 1; interval < 0; measurer == null
Method Detail

fill

public void fill()
          throws InterruptedException
Executes a loop which fills up the memory. The first action inside the loop is to sleep for interval. Next, it creates several new Object instances and adds them to a List local variable (so that they cannot be garbage collected as long as this method is being executed); numObjsCreatedPerLoop specifies how many Objects are created and added each time. The loop executes as long as measurer.getMemoryState.getAvailableRatio > fillPoint. Once the method returns, all the memory that was allocated will be eligible for garbage collection.

Throws:
InterruptedException

free

public void free()
Removes references to all the objects created by fill so that they can be garbage collected.