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

pack-priv final Class AgentLoader

extends Object
Class Inheritance
Imports
net.sf.ehcache.config.MemoryUnit, org.slf4j.Logger, .LoggerFactory, java.io.File, .FileOutputStream, .IOException, .InputStream, java.lang.instrument.Instrumentation, java.lang.management.ManagementFactory, java.lang.reflect.InvocationTargetException, .Method, java.net.URISyntaxException, .URL, .URLClassLoader, java.security.AccessController, .PrivilegedActionException, .PrivilegedExceptionAction, java.util.ArrayList, .List

This will try to load the agent using the Attach API of JDK6. If you are on an older JDK (v5) you can still use the agent by adding the -javaagent:[pathTojar] to your VM startup script
Author
Alex Snaps

Field Summary

Modifier and TypeField and Description
private static volatile Instrumentation
private static final String
private static final Logger
private static final String
private static final Method
private static final String
private static final Method
private static final Method

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean

Returns:

true if available
agentIsAvailable
()

Checks whether the agent is available

pack-priv static long

Returns:

size of the object in bytes
agentSizeOf
(Object
object to be sized
obj
)

Returns the size of this Java object as calculated by the loaded agent.

private static File
private static List<File>
private static Class<?>
pack-priv static boolean

Returns:

true if agent was loaded (which could have happened thought the -javaagent switch)
loadAgent
()

Attempts to load the agent through the Attach API

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instrumentationback to summary
private static volatile Instrumentation instrumentation
INSTRUMENTATION_INSTANCE_SYSTEM_PROPERTY_NAMEback to summary
private static final String INSTRUMENTATION_INSTANCE_SYSTEM_PROPERTY_NAME
LOGGERback to summary
private static final Logger LOGGER
SIZEOF_AGENT_CLASSNAMEback to summary
private static final String SIZEOF_AGENT_CLASSNAME
VIRTUAL_MACHINE_ATTACHback to summary
private static final Method VIRTUAL_MACHINE_ATTACH
VIRTUAL_MACHINE_CLASSNAMEback to summary
private static final String VIRTUAL_MACHINE_CLASSNAME
VIRTUAL_MACHINE_DETACHback to summary
private static final Method VIRTUAL_MACHINE_DETACH
VIRTUAL_MACHINE_LOAD_AGENTback to summary
private static final Method VIRTUAL_MACHINE_LOAD_AGENT

Constructor Detail

AgentLoaderback to summary
pack-priv AgentLoader()

Method Detail

agentIsAvailableback to summary
pack-priv static boolean agentIsAvailable()

Checks whether the agent is available

Returns:boolean

true if available

agentSizeOfback to summary
pack-priv static long agentSizeOf(Object obj)

Returns the size of this Java object as calculated by the loaded agent.

Parameters
obj:Object

object to be sized

Returns:long

size of the object in bytes

getAgentFileback to summary
private static File getAgentFile() throws IOException, URISyntaxException
getPossibleToolsJarsback to summary
private static List<File> getPossibleToolsJars()
getVirtualMachineClassback to summary
private static Class<?> getVirtualMachineClass() throws ClassNotFoundException
loadAgentback to summary
pack-priv static boolean loadAgent()

Attempts to load the agent through the Attach API

Returns:boolean

true if agent was loaded (which could have happened thought the -javaagent switch)

warnIfOSXback to summary
private static void warnIfOSX()