sizeof java object

前端 未结 6 1932
一生所求
一生所求 2020-11-30 13:25

How can we find out the size of a java object??

Example:

class Person{
    String name;  
    int age;  

    public Person(String n, int a){  
          


        
6条回答
  •  醉梦人生
    2020-11-30 13:42

    You can use the sizeof4j library to calculate the size of any object in java like SizeOf.shallowSize(new Integer(2))

提交回复
热议问题