Class AgentLoader

java.lang.Object
org.ehcache.sizeof.impl.AgentLoader

final class AgentLoader extends Object
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
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • SIZEOF_AGENT_CLASSNAME

      private static final String SIZEOF_AGENT_CLASSNAME
      See Also:
    • VIRTUAL_MACHINE_CLASSNAME

      private static final String VIRTUAL_MACHINE_CLASSNAME
      See Also:
    • VIRTUAL_MACHINE_ATTACH

      private static final Method VIRTUAL_MACHINE_ATTACH
    • VIRTUAL_MACHINE_DETACH

      private static final Method VIRTUAL_MACHINE_DETACH
    • VIRTUAL_MACHINE_LOAD_AGENT

      private static final Method VIRTUAL_MACHINE_LOAD_AGENT
    • instrumentation

      private static volatile Instrumentation instrumentation
    • INSTRUMENTATION_INSTANCE_SYSTEM_PROPERTY_NAME

      static final String INSTRUMENTATION_INSTANCE_SYSTEM_PROPERTY_NAME
      See Also:
  • Constructor Details

    • AgentLoader

      AgentLoader()
  • Method Details

    • getVirtualMachineClass

      private static Class<?> getVirtualMachineClass() throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • getPossibleToolsJars

      private static List<File> getPossibleToolsJars()
    • loadAgent

      static boolean loadAgent()
      Attempts to load the agent through the Attach API
      Returns:
      true if agent was loaded (which could have happened thought the -javaagent switch)
    • warnIfOSX

      private static void warnIfOSX()
    • getAgentFile

      private static File getAgentFile() throws IOException
      Throws:
      IOException
    • agentIsAvailable

      static boolean agentIsAvailable()
      Checks whether the agent is available
      Returns:
      true if available
    • agentSizeOf

      static long agentSizeOf(Object obj)
      Returns the size of this Java object as calculated by the loaded agent.
      Parameters:
      obj - object to be sized
      Returns:
      size of the object in bytes