查看创建前后的空闲内存不就知道了?如果一个不明显,你可以new 100个。嘿嘿

解决方案 »

  1.   

    没办法,不过可以参考jive的实现方法:public interface Cacheable {
      public int getSize();
    }
    public class CacheableLong implements Cacheable {
        /**
         * Wrapped long object.
         */
        private long longValue;    /**
         * Creates a new CacheableLong.
         *
         * @param string the Long object to wrap.
         */
        public CacheableLong(long longValue) {
            this.longValue = longValue;
        }    /**
         * Returns the Long wrapped by the CacheableLong object.
         *
         * @return the Long object.
         */
        public long getLong() {
            return longValue;
        }    //FROM THE CACHEABLE INTERFACE//    public int getSize() {
            return CacheSizes.sizeOfLong();
        }
    }
      

  2.   

    一个 Object 8bytes, 一个 Integer 16 ( 包括一个实例字段 8 bytes ) bytes.
    都是累加到的.