摘自JavaTM 2 SDK, Standard Edition DocumentationtotalMemory
public long totalMemory()
Returns the total amount of memory in the Java virtual machine. The value returned by this method may vary over time, depending on the host environment. 
Note that the amount of memory required to hold an object of any given type may be implementation-dependent. Returns:
the total amount of memory currently available for current and future objects, measured in bytes.我的E文一斑斑,对上面我是这样理解的:返回JVM总的MEMORY,这值受时间的影响,由主机决定
注意 the amount of memory required to hold an object of any given type may be implementation-dependent. (这里翻译不下去了 呵)返回的当前可用的MEMORY,单位:BYTE

解决方案 »

  1.   

    the amount of memory required to hold an object of any given type may be implementation-dependent
    任意给定类型的对象所需的内存大小可能和具体的实现有关
    (这里的具体实现我理解为该对象所属类的实现,不同的类可能有不同数量的数据成员,占用不同的内存空间)
      

  2.   

    totalMemory
    public long totalMemory()
    返回 Java 虚拟机中的内存总量。此方法返回的值可能随时间的推移而变化,这取决于主机环境。 
    注意,保存任意给定类型的一个对象所需的内存量可能取决于实现方法。 返回:
    目前为当前和后续对象提供的内存总量,以字节为单位。