Top Description Inners Fields Constructors Methods
net.sf.ehcache.pool.sizeof

public abstract Class SizeOf

extends Object
Class Inheritance
Known Direct Subclasses
net.sf.ehcache.pool.sizeof.UnsafeSizeOf, net.sf.ehcache.pool.sizeof.AgentSizeOf, net.sf.ehcache.pool.sizeof.ReflectionSizeOf
Imports
net.sf.ehcache.pool.Size, net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor, net.sf.ehcache.pool.sizeof.filter.SizeOfFilter, net.sf.ehcache.util.WeakIdentityConcurrentMap, org.slf4j.Logger, .LoggerFactory

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
SizeOf.CachingSizeOfVisitor

Will Cache already visited types

private class
SizeOf.SizeOfVisitor

Will return the sizeOf each instance

Field Summary

Modifier and TypeField and Description
private static final Logger
private final ObjectGraphWalker

Constructor Summary

AccessConstructor and Description
public
SizeOf(SizeOfFilter
The filter to apply
fieldFilter
,
boolean
whether to cache reflected fields
caching
)

Builds a new SizeOf that will filter fields according to the provided filter

Method Summary

Modifier and TypeMethod and Description
public Size

Returns:

the total size in bytes for these objects
deepSizeOf
(int
maximum depth of the object graph to traverse
maxDepth
,
boolean
true if the object traversal should be aborted when the max depth is exceeded
abortWhenMaxDepthExceeded
,
Object...
the root objects of the graphs to measure
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

public abstract long

Returns:

the object size in memory in bytes
sizeOf
(Object
the object to measure the size of
obj
)

Calculates the size in memory (heap) of the instance passed in, not navigating the down graph

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG
walkerback to summary
private final ObjectGraphWalker walker

Constructor Detail

SizeOfback to summary
public SizeOf(SizeOfFilter fieldFilter, boolean caching)

Builds a new SizeOf that will filter fields according to the provided filter

Parameters
fieldFilter:SizeOfFilter

The filter to apply

caching:boolean

whether to cache reflected fields

See Also
SizeOfFilter

Method Detail

deepSizeOfback to summary
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:int

maximum depth of the object graph to traverse

abortWhenMaxDepthExceeded:boolean

true if the object traversal should be aborted when the max depth is exceeded

obj:Object[]

the root objects of the graphs to measure

Returns:Size

the total size in bytes for these objects

See Also
sizeOf(Object)
sizeOfback to summary
public abstract long sizeOf(Object obj)

Calculates the size in memory (heap) of the instance passed in, not navigating the down graph

Parameters
obj:Object

the object to measure the size of

Returns:long

the object size in memory in bytes

net.sf.ehcache.pool.sizeof back to summary

private Class SizeOf.CachingSizeOfVisitor

extends Object
implements Visitor
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor

Will Cache already visited types

Field Summary

Modifier and TypeField and Description
private final WeakIdentityConcurrentMap<Class<?>, Long>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public long
visit(final Object
the reference at that node
object
)

Implements net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor.visit.

The visit method executed on each node
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final WeakIdentityConcurrentMap<Class<?>, Long> cache

Constructor Detail

CachingSizeOfVisitorback to summary
private CachingSizeOfVisitor()

Method Detail

visitback to summary
public long visit(final Object object)

Implements net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor.visit.

Doc from net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor.visit.

The visit method executed on each node

Parameters
object:Object

the reference at that node

Returns:long

a long for you to do things with...

net.sf.ehcache.pool.sizeof back to summary

private Class SizeOf.SizeOfVisitor

extends Object
implements Visitor
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor

Will return the sizeOf each instance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public long
visit(Object
the reference at that node
object
)

Implements net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor.visit.

The visit method executed on each node
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SizeOfVisitorback to summary
private SizeOfVisitor()

Method Detail

visitback to summary
public long visit(Object object)

Implements net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor.visit.

Doc from net.sf.ehcache.pool.sizeof.ObjectGraphWalker.Visitor.visit.

The visit method executed on each node

Parameters
object:Object

the reference at that node

Returns:long

a long for you to do things with...