freeMemory()
和totalMemory()
有什么区别?两者都是JVM当前可用的内存总量。
/**
*
* @return an approximation to the total amount of memory currently
* available for future allocated objects, measured in bytes.
*/
public native long freeMemory();
/**
*
* @return the total amount of memory currently available for current
* and future objects, measured in bytes.
*/
public native long totalMemory();
答案 0 :(得分:0)
freeMemory()
说for future
,而totalMemory()
说for current and future
。
从字面上看,freeMemory()
告诉新分配对象的内存,totalMemory()
告诉总内存(已分配的内存+可用内存)