ehcache

net.sf.ehcache.pool.sizeof
Class SizeOf

java.lang.Object
  extended by net.sf.ehcache.pool.sizeof.SizeOf
Direct Known Subclasses:
AgentSizeOf, ReflectionSizeOf, UnsafeSizeOf

public abstract class SizeOf
extends Object

Abstract sizeOf for Java. It will rely on a proper sizeOf to measure sizes of entire object graphs

Author:
Alex Snaps

Constructor Summary
SizeOf(SizeOfFilter fieldFilter, boolean caching)
          Builds a new SizeOf that will filter fields according to the provided filter
 
Method Summary
 Size deepSizeOf(int maxDepth, boolean abortWhenMaxDepthExceeded, Object... obj)
          Measures the size in memory (heap) of the objects passed in, walking their graph down Any overlap of the graphs being passed in will be recognized and only measured once
abstract  long sizeOf(Object obj)
          Calculates the size in memory (heap) of the instance passed in, not navigating the down graph
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SizeOf

public SizeOf(SizeOfFilter fieldFilter,
              boolean caching)
Builds a new SizeOf that will filter fields according to the provided filter

Parameters:
fieldFilter - The filter to apply
caching - whether to cache reflected fields
See Also:
SizeOfFilter
Method Detail

sizeOf

public abstract long sizeOf(Object obj)
Calculates the size in memory (heap) of the instance passed in, not navigating the down graph

Parameters:
obj - the object to measure the size of
Returns:
the object size in memory in bytes

deepSizeOf

public Size deepSizeOf(int maxDepth,
                       boolean abortWhenMaxDepthExceeded,
                       Object... obj)
Measures the size in memory (heap) of the objects passed in, walking their graph down Any overlap of the graphs being passed in will be recognized and only measured once

Parameters:
maxDepth - maximum depth of the object graph to traverse
abortWhenMaxDepthExceeded - true if the object traversal should be aborted when the max depth is exceeded
obj - the root objects of the graphs to measure
Returns:
the total size in bytes for these objects
See Also:
sizeOf(Object)

ehcache

Copyright 2001-2017, Terracotta, Inc.