本文主要是介绍[Java][MAT] Shallow Heap大小计算释疑,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
查看Mat文档时里面是这么描述Shallow Heap的:Shallowheap is the memory consumed by one object. An object needs 32 or 64 bits(depending on the OS architecture) per reference, 4 bytes per Integer, 8 bytesper Long, etc. Depending on the heap dump format the size may be adjusted (e.g.aligned to 8, etc...) to model better the real consumption of the VM.
照这么说,在Android机子上,每个Object的Shallow Heap开销应该是8 bytes 再加上该对象每个内部成员变量的内存开销。
Class Demo0 {}Class Demo1 {intint_num = 0;}
以上面两个类为例,Demo0的对象ShallowHeap大小应该是8bytes,那么Demo1的Shallow Heap大小应该是8 + 4 = 12bytes。但MAT的结果却显示值为16 bytes
这篇关于[Java][MAT] Shallow Heap大小计算释疑的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!