JavaTM 2 Platform
Standard Ed. 6

java.lang.management
类 MemoryNotificationInfo

java.lang.Object
  继承者 java.lang.management.MemoryNotificationInfo

public class MemoryNotificationInfo
extends Object

关于内存通知的信息。

当 Java 虚拟机检测到内存池的内存使用量超过了阈值时,MemoryMXBean 将发出内存通知。发出的通知将包含关于检测到的情况的内存通知信息:

表示 MemoryNotificationInfo 对象的 CompositeData 存储在通知用户数据中。提供了表单方法将 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 发出的通知类型为:

从以下版本开始:
1.5

字段摘要
static String MEMORY_COLLECTION_THRESHOLD_EXCEEDED
          表示当 Java 虚拟机对内存池中的不使用的对象进行了回收工作之后,内存池的内存使用量大于或等于其集合使用量阈值的通知类型。
static String MEMORY_THRESHOLD_EXCEEDED
          表示内存池的内存使用量已达到或超过其使用量阈值的通知类型。
 
构造方法摘要
MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
          构造一个 MemoryNotificationInfo 对象。
 
方法摘要
static MemoryNotificationInfo from(CompositeData cd)
          返回由给定 CompositeData 表示的 MemoryNotificationInfo 对象。
 long getCount()
          返回构造通知时内存使用量超过阈值的次数。
 String getPoolName()
          返回触发此通知的内存池的名称。
 MemoryUsage getUsage()
          返回构造此通知时内存池的内存使用量。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

MEMORY_THRESHOLD_EXCEEDED

public static final String MEMORY_THRESHOLD_EXCEEDED
表示内存池的内存使用量已达到或超过其使用量阈值的通知类型。此通知由 MemoryMXBean 发出。后续的使用量阈值超过情况不会导致更多的通知,一直到内存使用量返回到小于使用量阈值的状态为止。此通知类型的值为 java.management.memory.threshold.exceeded

另请参见:
常量字段值

MEMORY_COLLECTION_THRESHOLD_EXCEEDED

public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED
表示当 Java 虚拟机对内存池中的不使用的对象进行了回收工作之后,内存池的内存使用量大于或等于其集合使用量阈值的通知类型。此通知由 MemoryMXBean 发出。此通知类型的值为 java.management.memory.collection.threshold.exceeded

另请参见:
常量字段值
构造方法详细信息

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()
返回构造通知时内存使用量超过阈值的次数。对于使用量阈值通知,此计数将为阈值计数。对于集合使用量阈值通知,此计数将为集合使用量阈值计数

返回:
构造通知时,内存使用量超过阈值的次数。

from

public static MemoryNotificationInfo from(CompositeData cd)
返回由给定 CompositeData 表示的 MemoryNotificationInfo 对象。此给定的 CompositeData 必须包含以下属性:
属性名称 类型
poolName java.lang.String
usage javax.management.openmbean.CompositeData
count java.lang.Long

参数:
cd - 表示 MemoryNotificationInfoCompositeData
返回:
如果 cd 不为 null,则返回由 cd 表示的 MemoryNotificationInfo 对象;否则,返回 null
抛出:
IllegalArgumentException - 如果 cd 不表示 MemoryNotificationInfo 对象。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only