Package org.ehcache.sizeof
Class SizeOf
- java.lang.Object
-
- org.ehcache.sizeof.SizeOf
-
- Direct Known Subclasses:
AgentSizeOf,ReflectionSizeOf,UnsafeSizeOf
public abstract class SizeOf extends java.lang.ObjectAbstract sizeOf for Java. It will rely on a proper sizeOf to measure sizes of entire object graphs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classSizeOf.CachingSizeOfVisitorWill Cache already visited typesprivate classSizeOf.SizeOfVisitorWill return the sizeOf each instance
-
Field Summary
Fields Modifier and Type Field Description private ObjectGraphWalkerwalker
-
Constructor Summary
Constructors Constructor Description SizeOf(SizeOfFilter fieldFilter, boolean caching, boolean bypassFlyweight)Builds a new SizeOf that will filter fields according to the provided filter
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description longdeepSizeOf(java.lang.Object... obj)longdeepSizeOf(VisitorListener listener, java.lang.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 oncestatic SizeOfnewInstance(boolean bypassFlyweight, boolean cache, SizeOfFilter... filters)static SizeOfnewInstance(SizeOfFilter... filters)abstract longsizeOf(java.lang.Object obj)Calculates the size in memory (heap) of the instance passed in, not navigating the down graph
-
-
-
Field Detail
-
walker
private final ObjectGraphWalker walker
-
-
Constructor Detail
-
SizeOf
public SizeOf(SizeOfFilter fieldFilter, boolean caching, boolean bypassFlyweight)
Builds a new SizeOf that will filter fields according to the provided filter- Parameters:
fieldFilter- The filter to applycaching- whether to cache reflected fieldsbypassFlyweight- whether "Flyweight Objects" are to be ignored- See Also:
SizeOfFilter
-
-
Method Detail
-
sizeOf
public abstract long sizeOf(java.lang.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 long deepSizeOf(VisitorListener listener, java.lang.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:
listener- A listener to visited objectsobj- the root objects of the graphs to measure- Returns:
- the total size in bytes for these objects
- See Also:
sizeOf(Object)
-
deepSizeOf
public long deepSizeOf(java.lang.Object... obj)
-
newInstance
public static SizeOf newInstance(SizeOfFilter... filters)
-
newInstance
public static SizeOf newInstance(boolean bypassFlyweight, boolean cache, SizeOfFilter... filters)
-
-