public class MemoryNotificationInfo extends Object
存储器通知由发射MemoryMXBean当Java虚拟机检测到内存池的内存使用量超过阈值。 发出的通知将包含有关检测到的条件的内存通知信息:
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发出的通知类型有:
usage threshold exceeded notification 。 collection usage threshold exceeded notification 。 | Modifier and Type | Field and Description |
|---|---|
static String |
MEMORY_COLLECTION_THRESHOLD_EXCEEDED
通知类型表示内存池的内存使用量大于或等于其
collection usage threshold之后,Java虚拟机已经花费了在该内存池中回收未使用的对象的努力。
|
static String |
MEMORY_THRESHOLD_EXCEEDED
通知类型表示内存池的内存使用量已达到或超过其
usage threshold值。
|
| Constructor and Description |
|---|
MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
构造一个
MemoryNotificationInfo对象。
|
| Modifier and Type | Method and Description |
|---|---|
static MemoryNotificationInfo |
from(CompositeData cd)
返回由给定的
CompositeData表示的
MemoryNotificationInfo对象。
|
long |
getCount()
返回构建通知时内存使用量超过阈值的次数。
|
String |
getPoolName()
返回触发此通知的内存池的名称。
|
MemoryUsage |
getUsage()
构建此通知时返回内存池的内存使用情况。
|
public static final String MEMORY_THRESHOLD_EXCEEDED
MemoryMXBean发布 。
随后交叉使用阈值直到存储器使用已经返回到小于使用阈值为止才进一步通知。
此通知类型的值为java.management.memory.threshold.exceeded 。
public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED
MemoryMXBean发布 。
此通知类型的值为java.management.memory.collection.threshold.exceeded 。
public MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
poolName - 触发此通知的内存池的名称。
usage - 内存池的内存使用情况。
count - 临界值计数。
public String getPoolName()
public MemoryUsage getUsage()
public long getCount()
threshold count 。
对于采集阈值通知,此计数将为collection usage threshold count 。
public static MemoryNotificationInfo from(CompositeData cd)
Attribute Name Type poolName java.lang.String usage javax.management.openmbean.CompositeData count java.lang.Long
cd -
CompositeData代表
MemoryNotificationInfo
IllegalArgumentException - 如果
cd不代表
MemoryNotificationInfo对象。
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.