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
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