Skip to content

a simple class, used to calculate java Object size

Notifications You must be signed in to change notification settings

NickDaDa/java-sizeof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

java-sizeof

a simple class, used to calculate java Object size, implemented by JDK above 1.5, resolved the manifest.mf file add pre-class attr problem . origin doc refer https://www.baeldung.com/java-size-of-object

quickStart

1.clone code & build in your maven repository
2.import this jar file to your maven project by pom.xml
3.config run/debug arguments, add -javaagent:"ClassPath\InstrumentationAgent-0.0.1-SNAPSHOT.jar" to VM Options
4.import cn.com.instrument.InstrumentationAgent;
5.insert ref code:

public static void printObjectSize(Object object) {
      System.out.println("Object type: " + object.getClass() +
        ", size: " + InstrumentationAgent.getObjectSize(object) + " bytes");
  }
  
6.start run/debug

About

a simple class, used to calculate java Object size

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages