本文整理匯總了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());
}
}
}