twitter-archive / commons

Twitter common libraries for python and the JVM (deprecated)
http://twitter.github.com/commons
Other
2.1k stars 565 forks source link

I find a bug in src/java/com/twitter/common/objectsize/ObjectSizeCalculator.java #438

Open dslztx opened 7 years ago

dslztx commented 7 years ago

There are some classes as follows:

class A {
    int a;
}

class B extends A {
    long b;
}

class C extends B {
    char c;
}

public class Main
{
public static void main(String[] args)
{
    C c=new C();
    System.out.println(ObjectSizeCalculator.getObjectSize(c));
}
}

In 32 bits JDK,the result of your program execution is 24,but the exact result is 32. I also write a program for calculating java object size,please take a look at java-object-size