Welcome!
This project allow us check how much to find out how much space a Java object takes up in memory.
This is Maven project.
If u want to find detailed instructions click on this link.
In this readme I describe short instructions how to run this project into your PC.
If u want known more about Instrumentation
click on this word.
- The application consists of 2 modules.
- An app modules:
InstrumentationAgent
: In this module exist class was designed to work as a Java agent that can be loaded into a Java application to measure the size of objects in memory using theInstrumentation API
. It's important to initialize the globalInstrumentation field with a valid Instrumentation instance using the premain method before callinggetObjectSize
;InstrumentationExample
: This class just show how much a Java object takes up in memory. If u want u can change this class.
- I would you recommended to clone my project from the GitHub.
If u wanna do this please use this command:
git clone https://github.com/dima666Sik/Get-takes-up-size-of-Java-objects-in-memory.git
-
To run this project you will need to install:
- JDK 8 or higher;
-
If you continue, u must generate .jar for
InstrumentationAgent
andInstrumentationExample
as well.
Open terminal and go to those modules and use command below compiles the source code, runs tests, and packages the project into a JAR or other distributable format. It also installs the built artifact into your local Maven repository.
mvn clean install
- To run
InstrumentationExample
u can to return into parent module (usingcd ..
) and use command below.
java -javaagent:".\InstrumentationAgent\target\InstrumentationAgent-1.0-SNAPSHOT.jar" -jar .\InstrumentationExample\target\InstrumentationExample-1.
0-SNAPSHOT.jar
U can see this result if u do all steps right.