Skip to content

This project allow us check how much to find out how much space a Java object takes up in memory. This is Maven project.

Notifications You must be signed in to change notification settings

dima666Sik/Get-takes-up-size-of-Java-objects-in-memory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Way how to get estimated size of Java objects

List of Contents


Description

Preview, I hope you enjoy it 😊

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.


Project Structure

  • 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 the Instrumentation API. It's important to initialize the globalInstrumentation field with a valid Instrumentation instance using the premain method before calling getObjectSize;
    • InstrumentationExample: This class just show how much a Java object takes up in memory. If u want u can change this class.

Usage

  1. 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
  1. To run this project you will need to install:

    • JDK 8 or higher;
  2. If you continue, u must generate .jar for InstrumentationAgent and InstrumentationExample 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
  1. To run InstrumentationExample u can to return into parent module (using cd ..) and use command below.
java -javaagent:".\InstrumentationAgent\target\InstrumentationAgent-1.0-SNAPSHOT.jar" -jar .\InstrumentationExample\target\InstrumentationExample-1.
0-SNAPSHOT.jar

Result

U can see this result if u do all steps right.

Result

Author Info

Back To The Top

About

This project allow us check how much to find out how much space a Java object takes up in memory. This is Maven project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages