org.expasy.jpl.commons.base.mem
Class ObjectSizeEstimator

java.lang.Object
  extended by org.expasy.jpl.commons.base.mem.ObjectSizeEstimator

public final class ObjectSizeEstimator
extends Object

Estimate the average memory (in bytes) used to store an object from a collection of objects.

Version:
1.0
Author:
nikitin

Method Summary
 double getAvgSizeOfObject()
           
 double getDefaultMemoryRatio()
           
 double getFreeMemoryRatio()
           
 int getMaxObjectNumber()
           
 long getMemoryCap()
           
 long getMinMemoryForEstimation()
           
 double getUsedMemorySize()
           
 void init()
           
 boolean isBeyondMemoryCap(long memorySize)
          Test if memory is sufficient to store all.
 boolean isSufficientDataForEstimation()
           
 void keepTrack()
           
 long maxMemoryBlock(long memorySize)
           
static ObjectSizeEstimator newInstance()
           
 void setBlockMemoryLimit(long size)
          Set the memory limit.
 void setMaxMemoryRatio(double ratio)
          Set the max free memory ratio.
 void start()
          Init the memory size estimation.
 void stop(int elementNumber)
          Stop the current memory size estimation.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

newInstance

public static ObjectSizeEstimator newInstance()

init

public void init()

setBlockMemoryLimit

public void setBlockMemoryLimit(long size)
Set the memory limit.

Parameters:
size - the max bytes.

setMaxMemoryRatio

public void setMaxMemoryRatio(double ratio)
Set the max free memory ratio.

Parameters:
ratio - the maximum allocated part of the memory.

getDefaultMemoryRatio

public double getDefaultMemoryRatio()

getFreeMemoryRatio

public double getFreeMemoryRatio()

start

public void start()
Init the memory size estimation.


keepTrack

public void keepTrack()

stop

public void stop(int elementNumber)
Stop the current memory size estimation.

Parameters:
elementNumber - the number of instanciated elements.

getAvgSizeOfObject

public final double getAvgSizeOfObject()
Returns:
the average memory by instanciated element.

getUsedMemorySize

public final double getUsedMemorySize()
Returns:
the overall used memory.

getMaxObjectNumber

public int getMaxObjectNumber()
Returns:
the maximum number of objects.

getMemoryCap

public long getMemoryCap()

isBeyondMemoryCap

public boolean isBeyondMemoryCap(long memorySize)
Test if memory is sufficient to store all.

Parameters:
memorySize - the memory to compare with limits.
Returns:
true if the needed size > allowed memory.

getMinMemoryForEstimation

public final long getMinMemoryForEstimation()

isSufficientDataForEstimation

public boolean isSufficientDataForEstimation()

maxMemoryBlock

public long maxMemoryBlock(long memorySize)

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.