Package org.ehcache.sizeof.impl
Class AgentSizeOf
- java.lang.Object
-
- org.ehcache.sizeof.SizeOf
-
- org.ehcache.sizeof.impl.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 Inspired by Dr. Heinz Kabutz's Java Specialist Newsletter Issue #142
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
AGENT_LOADED
static java.lang.String
BYPASS_LOADING
System property name to bypass attaching to the VM and loading of Java agent to measure Object sizes.
-
Constructor Summary
Constructors Constructor Description AgentSizeOf()
Builds a new SizeOf that will not filter fields and will cache reflected fieldsAgentSizeOf(SizeOfFilter filter)
Builds a new SizeOf that will filter fields according to the provided filter and will cache reflected fieldsAgentSizeOf(SizeOfFilter filter, boolean caching, boolean bypassFlyweight)
Builds a new SizeOf that will filter fields according to the provided filter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
sizeOf(java.lang.Object obj)
Calculates the size in memory (heap) of the instance passed in, not navigating the down graph-
Methods inherited from class org.ehcache.sizeof.SizeOf
deepSizeOf, deepSizeOf, newInstance, newInstance
-
-
-
-
Field Detail
-
BYPASS_LOADING
public static final java.lang.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
-
AGENT_LOADED
private static final boolean AGENT_LOADED
-
-
Constructor Detail
-
AgentSizeOf
public AgentSizeOf() throws java.lang.UnsupportedOperationException
Builds a new SizeOf that will not filter fields and will cache reflected fields- Throws:
java.lang.UnsupportedOperationException
- If agent couldn't be loaded or isn't present- See Also:
AgentSizeOf(SizeOfFilter, boolean, boolean)
-
AgentSizeOf
public AgentSizeOf(SizeOfFilter filter) throws java.lang.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:
java.lang.UnsupportedOperationException
- If agent couldn't be loaded or isn't present- See Also:
AgentSizeOf(SizeOfFilter, boolean, boolean)
,SizeOfFilter
-
AgentSizeOf
public AgentSizeOf(SizeOfFilter filter, boolean caching, boolean bypassFlyweight) throws java.lang.UnsupportedOperationException
Builds a new SizeOf that will filter fields according to the provided filter- Parameters:
filter
- The filter to applycaching
- whether to cache reflected fieldsbypassFlyweight
- whether "Flyweight Objects" are to be ignored- Throws:
java.lang.UnsupportedOperationException
- If agent couldn't be loaded or isn't present- See Also:
SizeOfFilter
-
-
Method Detail
-
sizeOf
public long sizeOf(java.lang.Object obj)
Description copied from class:SizeOf
Calculates the size in memory (heap) of the instance passed in, not navigating the down graph
-
-