public class MemoryNotificationInfo extends Object
一个内存通知发出时MemoryMXBean
java虚拟机检测到一个内存池的内存使用量超过阈值。所发出的通知将包含有关所检测到的状态的内存通知信息:
usage threshold count
。收藏门槛的通知,这算是collection usage threshold count
。一个CompositeData
代表MemoryNotificationInfo对象存储在一个notification
的user data
。的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.