Java一个对象占用内存的大小查看
1.maven 导入相关依赖
<!-- https://mvnrepository.com/artifact/com.carrotsearch/java-sizeof --> <dependency> <groupId>com.carrotsearch</groupId> <artifactId>java-sizeof</artifactId> <version>0.0.5</version> </dependency>
2.代码打印内存大小
log.info("RamUsageEstimator数据大小:{}", RamUsageEstimator.sizeOf(xxxxx));