- java.lang.Object
-
- java.lang.management.MemoryNotificationInfo
-
public class MemoryNotificationInfo extends Object
有关内存通知的信息。当Java虚拟机检测到内存池的内存使用量超过阈值时,
MemoryMXBean会发出内存通知。 发出的通知将包含有关检测到的条件的内存通知信息:- 内存池的名称。
- 构建通知时内存池的内存使用情况。
- 构建通知时内存使用量超过阈值的次数。 对于使用阈值通知,此计数将为
usage threshold count。 对于采集阈值通知,此计数将为collection usage threshold count。
A
CompositeData表示MemoryNotificationInfo对象存储在user data的notification中 。 提供from方法将其从CompositeData转换为MemoryNotificationInfo对象。 例如:Notification notif; // receive the notification emitted by MemoryMXBean and set to notif ... String notifType = notif.getType(); if (notifType.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED) || notifType.equals(MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED)) { // retrieve the memory notification information CompositeData cd = (CompositeData) notif.getUserData(); MemoryNotificationInfo info = MemoryNotificationInfo.from(cd); .... }MemoryMXBean发出的通知类型有:- A
usage threshold exceeded notification。
当内存池的内存使用量增加并达到或超过其usage threshold值时,将发出此通知。 随后交叉使用阈值直到存储器使用已经返回到小于使用阈值为止才进一步通知。 - A
collection usage threshold exceeded notification。
当Java虚拟机花费了回收该内存池中未使用的对象的努力时,内存池的内存使用大于或等于其collection usage threshold时,将会发出此通知。
- 从以下版本开始:
- 1.5
-
-
Field Summary
Fields Modifier and Type Field 描述 static StringMEMORY_COLLECTION_THRESHOLD_EXCEEDED通知类型表示在Java虚拟机已经花费了回收该内存池中的未使用对象的努力之后,内存池的内存使用大于或等于其 collection usage threshold 。static StringMEMORY_THRESHOLD_EXCEEDED通知类型表示内存池的内存使用量已达到或超过其 usage threshold值。
-
构造方法摘要
构造方法 Constructor 描述 MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)构造一个MemoryNotificationInfo对象。
-
方法摘要
所有方法 静态方法 接口方法 具体的方法 Modifier and Type 方法 描述 static MemoryNotificationInfofrom(CompositeData cd)返回由给定的CompositeData表示的MemoryNotificationInfo对象。longgetCount()返回构建通知时内存使用量超过阈值的次数。StringgetPoolName()返回触发此通知的内存池的名称。MemoryUsagegetUsage()构建此通知时返回内存池的内存使用情况。
-
-
-
字段详细信息
-
MEMORY_THRESHOLD_EXCEEDED
public static final String MEMORY_THRESHOLD_EXCEEDED
指示内存池的内存使用量达到或超过其usage threshold值的通知类型。 该通知由MemoryMXBean发出。 随后交叉使用阈值直到存储器使用已经返回到小于使用阈值为止才进一步通知。 此通知类型的值为java.management.memory.threshold.exceeded。- 另请参见:
- Constant Field Values
-
MEMORY_COLLECTION_THRESHOLD_EXCEEDED
public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED
通知类型表示内存池的内存使用大于或等于其collection usage threshold之后,Java虚拟机已经花费了在该内存池中回收未使用的对象的努力。 此通知由MemoryMXBean发出。 此通知类型的值为java.management.memory.collection.threshold.exceeded。- 另请参见:
- Constant Field Values
-
-
构造方法详细信息
-
MemoryNotificationInfo
public MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
构造一个MemoryNotificationInfo对象。- 参数
-
poolName- 触发此通知的内存池的名称。 -
usage- 内存池的内存使用情况。 -
count- 临界值计数。
-
-
方法详细信息
-
getPoolName
public String getPoolName()
返回触发此通知的内存池的名称。 内存池的使用率已超过阈值。- 结果
- 触发此通知的内存池的名称。
-
getUsage
public MemoryUsage getUsage()
构建此通知时返回内存池的内存使用情况。- 结果
- 构建此通知时内存池的内存使用情况。
-
getCount
public long getCount()
返回构建通知时内存使用量超过阈值的次数。 对于使用阈值通知,此计数将为threshold count。 对于收集阈值通知,此计数将为collection usage threshold count。- 结果
- 构建通知时内存使用量超过阈值的次数。
-
from
public static MemoryNotificationInfo from(CompositeData cd)
返回由给定的CompositeData表示的MemoryNotificationInfo对象。 给定的CompositeData必须包含以下属性:Attribute Name Type poolName java.lang.Stringusage javax.management.openmbean.CompositeDatacount java.lang.Long- 参数
-
cd-CompositeData代表MemoryNotificationInfo - 结果
-
一个
MemoryNotificationInfo对象,由cd表示,如果cd不是null;null否则。 - 异常
-
IllegalArgumentException- 如果cd不表示MemoryNotificationInfo对象。
-
-