测试代码
引入maven环境
1
2
3
4
5
<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<version>0.9</version>
</dependency>
测试代码
1
2
3
4
5
6
7
8
9
10
11
12
13
public class ObjectRAM {
public static void main(String[] args) {
System.out.println("**初始化Object**");
Object o = new Object();
System.out.println(ClassLayout.parseInstance(o).toPrintable());
System.out.println("**初始化Object[]**");
Object[] oa = new Object[15];
System.out.println(ClassLayout.parseInstance(oa).toPrintable());
}
}