本文整理汇总了Java中java.lang.management.GarbageCollectorMXBean.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java GarbageCollectorMXBean.isValid方法的具体用法?Java GarbageCollectorMXBean.isValid怎么用?Java GarbageCollectorMXBean.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.management.GarbageCollectorMXBean
的用法示例。
在下文中一共展示了GarbageCollectorMXBean.isValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGCStatst
import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
/**
* Returns a map of garbage collectors and their stats.
* The first object in the array is the total count since JVM start and the
* second is the total time (ms) since JVM start.
* If a garbage collectors does not support the collector MXBean, then it
* will not be represented in the map.
* @return A non-null map of garbage collectors and their metrics. The map
* may be empty.
*/
public static Map<String, Long[]> getGCStatst() {
final List<GarbageCollectorMXBean> gcBeans =
ManagementFactory.getGarbageCollectorMXBeans();
final Map<String, Long[]> map = new HashMap<String, Long[]>(gcBeans.size());
for (final GarbageCollectorMXBean bean : gcBeans) {
if (!bean.isValid() || bean.getCollectionCount() < 0 ||
bean.getCollectionTime() < 0) {
continue;
}
final Long[] measurements = new Long[]{
bean.getCollectionCount(),
bean.getCollectionTime()
};
map.put(bean.getName().replace(" ", "_"), measurements);
}
return map;
}
示例2: initGC
import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
private void initGC() {
List<GarbageCollectorMXBean> l = ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean item : l) {
if (item.isValid() && !gcMap.containsKey(item)) {
gcMap.put(item, this.f.createStatistics(gcType, item.getName(), this.id));
}
}
}
示例3: refreshGC
import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
private void refreshGC() {
Iterator<Map.Entry<GarbageCollectorMXBean, Statistics>> it = gcMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<GarbageCollectorMXBean, Statistics> me = it.next();
GarbageCollectorMXBean gc = me.getKey();
Statistics s = me.getValue();
if (!gc.isValid()) {
s.close();
it.remove();
} else {
s.setLong(gc_collectionsId, gc.getCollectionCount());
s.setLong(gc_collectionTimeId, gc.getCollectionTime());
}
}
}
示例4: refreshGC
import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
private void refreshGC() {
Iterator<Map.Entry<GarbageCollectorMXBean,Statistics>> it = gcMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<GarbageCollectorMXBean,Statistics> me = it.next();
GarbageCollectorMXBean gc = me.getKey();
Statistics s = me.getValue();
if (!gc.isValid()) {
s.close();
it.remove();
} else {
s.setLong(gc_collectionsId, gc.getCollectionCount());
s.setLong(gc_collectionTimeId, gc.getCollectionTime());
}
}
}