ehcache

net.sf.ehcache.pool.sizeof
Class AgentSizeOf

java.lang.Object
  extended by net.sf.ehcache.pool.sizeof.SizeOf
      extended by net.sf.ehcache.pool.sizeof.AgentSizeOf

public class AgentSizeOf
extends SizeOf

SizeOf implementation that relies on a Java agent to be loaded to do the measurement It will try to load the agent through the JDK6 Attach API if available All it's constructor do throw UnsupportedOperationException if the agent isn't present or couldn't be loaded dynamically

Author:
Chris Dennis, Alex Snaps

Field Summary
static String BYPASS_LOADING
          System property name to bypass attaching to the VM and loading of Java agent to measure Object sizes.
 
Constructor Summary
AgentSizeOf()
          Builds a new SizeOf that will not filter fields and will cache reflected fields
AgentSizeOf(SizeOfFilter filter)
          Builds a new SizeOf that will filter fields according to the provided filter and will cache reflected fields
AgentSizeOf(SizeOfFilter filter, boolean caching)
          Builds a new SizeOf that will filter fields according to the provided filter
 
Method Summary
 long sizeOf(Object obj)
          Calculates the size in memory (heap) of the instance passed in, not navigating the down graph
 
Methods inherited from class net.sf.ehcache.pool.sizeof.SizeOf
deepSizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYPASS_LOADING

public static final String BYPASS_LOADING
System property name to bypass attaching to the VM and loading of Java agent to measure Object sizes.

See Also:
Constant Field Values
Constructor Detail

AgentSizeOf

public AgentSizeOf()
            throws UnsupportedOperationException
Builds a new SizeOf that will not filter fields and will cache reflected fields

Throws:
UnsupportedOperationException - If agent couldn't be loaded or isn't present
See Also:
AgentSizeOf(net.sf.ehcache.pool.sizeof.filter.SizeOfFilter, boolean)

AgentSizeOf

public AgentSizeOf(SizeOfFilter filter)
            throws UnsupportedOperationException
Builds a new SizeOf that will filter fields according to the provided filter and will cache reflected fields

Parameters:
filter - The filter to apply
Throws:
UnsupportedOperationException - If agent couldn't be loaded or isn't present
See Also:
AgentSizeOf(net.sf.ehcache.pool.sizeof.filter.SizeOfFilter, boolean), SizeOfFilter

AgentSizeOf

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

Parameters:
filter - The filter to apply
caching - whether to cache reflected fields
Throws:
UnsupportedOperationException - If agent couldn't be loaded or isn't present
See Also:
SizeOfFilter
Method Detail

sizeOf

public long sizeOf(Object obj)
Description copied from class: SizeOf
Calculates the size in memory (heap) of the instance passed in, not navigating the down graph

Specified by:
sizeOf in class SizeOf
Parameters:
obj - the object to measure the size of
Returns:
the object size in memory in bytes

ehcache

Copyright 2001-2015, Terracotta, Inc.