public class MemoryUsage extends Object
一个MemoryUsage对象包含四个值:
init | represents the initial amount of memory (in bytes) that the Java virtual machine requests from the operating system for memory management during startup. The Java virtual machine may request additional memory from the operating system and may also release memory to the system over time. The value of init may be undefined. |
used | represents the amount of memory currently used (in bytes). |
committed | represents the amount of memory (in bytes) that is guaranteed to be available for use by the Java virtual machine. The amount of committed memory may change over time (increase or decrease). The Java virtual machine may release memory to the system and committed could be less than init. committed will always be greater than or equal to used. |
max | represents the maximum amount of memory (in bytes) that can be used for memory management. Its value may be undefined. The maximum amount of memory may change over time if defined. The amount of used and committed memory will always be less than or equal to max if max is defined. A memory allocation may fail if it attempts to increase the used memory such that used > committed even if used <= max would still be true (for example, when the system is low on virtual memory). |
---------------------------------------------- + +//////////////// | + +//////////////// | + +---------------------------------------------- + +| -------- |初始化| --------------- |习惯于| --------------------------- |坚信的| ---------------------------------------------- |最大值
CompositeData
from
方法。
Constructor and Description |
---|
MemoryUsage(long init, long used, long committed, long max)
构建了一个
MemoryUsage对象。
|
Modifier and Type | Method and Description |
---|---|
static MemoryUsage |
from(CompositeData cd)
返回一个给定的
CompositeData代表
MemoryUsage对象。
|
long |
getCommitted()
返回字节,致力为java虚拟机使用的内存量。
|
long |
getInit()
返回的内存量在字节,java虚拟机从最初请求的内存管理操作系统。
|
long |
getMax()
返回可用于内存管理的字节数的最大内存量。
|
long |
getUsed()
返回字节数的使用内存量。
|
String |
toString()
返回此内存使用的描述性表示形式。
|
public MemoryUsage(long init, long used, long committed, long max)
init
-初始量的内存字节,java虚拟机分配;或
-1如果未定义。
used
-使用内存的字节数量。
committed
-字节的内存量。
max
-字节可以使用的最大内存量;或
-1如果未定义。
IllegalArgumentException
public long getInit()
public long getUsed()
public long getCommitted()
public long getMax()
此内存量不保证是可用于内存管理,如果它是大于承诺的内存量。java虚拟机可能无法分配内存,即使所用的内存不超过这个最大尺寸。
public static MemoryUsage from(CompositeData cd)
Attribute Name Type init java.lang.Long used java.lang.Long committed java.lang.Long max java.lang.Long
cd
-
CompositeData代表
MemoryUsage
IllegalArgumentException
-如果
cd并不代表上述属性
MemoryUsage。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.