Class InstrumentationAgent
java.lang.Object
edu.fiu.adwise.homomorphic_encryption.misc.InstrumentationAgent
This class serves as a Java instrumentation agent, allowing the measurement of object sizes at runtime.
It uses the
Instrumentation API to provide functionality for determining the size of objects in memory.
To use this agent, it must be specified as a Java agent in the JVM arguments. The premain method is invoked before the application's main method, initializing the instrumentation instance.
For more details, refer to: Baeldung: Measuring Object Size in Java
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longgetObjectSize(Object object) Returns the size of the specified object in bytes.static voidpremain(String agentArgs, Instrumentation inst) The premain method is called by the JVM before the application's main method.
-
Constructor Details
-
InstrumentationAgent
public InstrumentationAgent()
-
-
Method Details
-
premain
The premain method is called by the JVM before the application's main method. It initializes theInstrumentationinstance for use in the agent.- Parameters:
agentArgs- The agent arguments passed to the JVM.inst- TheInstrumentationinstance provided by the JVM.
-
getObjectSize
Returns the size of the specified object in bytes.- Parameters:
object- The object whose size is to be measured.- Returns:
- The size of the object in bytes.
- Throws:
IllegalStateException- If the agent has not been initialized.
-