计算机技术实战

纸上得来终觉浅,绝知此事要躬行。

Download this project as a .zip file Download this project as a tar.gz file

内存优化实践

各个类型占用的字节数

如下类:

public class MwpObj {
    byte aByte = 1;
    char aChar = 1;
    short aShort = 1;
    int anInt = 1;
    long aLong = 1;
    float aFloat = 1;
    double aDouble = 1;
    Object obj = new Object();
}

占用内存的情况如下(已字节为单位):