jol 查看对象头内容和对象大小
作者:
全都是泡沫啦 | 来源:发表于
2019-12-19 20:40 被阅读0次import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.info.GraphLayout;
/**
* @author paul
* @description
* @date 2019/12/19
* 是否开启指针压缩 -XX:-UseCompressedOops
*
<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<version>0.9</version>
</dependency>
*/
public class TestObjectSize {
private Object o = new Object();
public static void main(String[] args) {
//查看对象内部信息
TestObjectSize testObjectSize = new TestObjectSize();
System.out.println(ClassLayout.parseInstance(testObjectSize).toPrintable());
System.out.println("=================");
synchronized (testObjectSize){
System.out.println(ClassLayout.parseInstance(testObjectSize).toPrintable());
}
System.out.println("=================");
System.out.println(GraphLayout.parseInstance(testObjectSize).toPrintable());
System.out.println("=================");
System.out.println(GraphLayout.parseInstance(testObjectSize).totalSize());
System.out.println(ClassLayout.parseInstance(new Object[0]).toPrintable());
}
}
本文标题:jol 查看对象头内容和对象大小
本文链接:https://www.haomeiwen.com/subject/qruvnctx.html
网友评论