use of java.lang.management.GarbageCollectorMXBean in project gradle by gradle.
the class GarbageCollectionCheck method run.
@Override
public void run() {
List<GarbageCollectorMXBean> garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
GarbageCollectorMXBean garbageCollectorMXBean = CollectionUtils.findFirst(garbageCollectorMXBeans, new Spec<GarbageCollectorMXBean>() {
@Override
public boolean isSatisfiedBy(GarbageCollectorMXBean mbean) {
return mbean.getName().equals(garbageCollector);
}
});
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeans) {
String pool = memoryPoolMXBean.getName();
if (memoryPools.contains(pool)) {
GarbageCollectionEvent event = new GarbageCollectionEvent(System.currentTimeMillis(), memoryPoolMXBean.getCollectionUsage(), garbageCollectorMXBean.getCollectionCount());
events.get(pool).slideAndInsert(event);
}
}
}
use of java.lang.management.GarbageCollectorMXBean in project bazel by bazelbuild.
the class GCStatsRecorder method getCurrentGcStats.
public Iterable<GCStat> getCurrentGcStats() {
List<GCStat> stats = new ArrayList<>();
for (GarbageCollectorMXBean mxBean : mxBeans) {
String name = mxBean.getName();
GCStat initStat = Preconditions.checkNotNull(initialData.get(name));
stats.add(new GCStat(name, mxBean.getCollectionCount() - initStat.getNumCollections(), mxBean.getCollectionTime() - initStat.getTotalTimeInMs()));
}
return stats;
}
use of java.lang.management.GarbageCollectorMXBean in project hadoop by apache.
the class JvmPauseMonitor method getGcTimes.
private Map<String, GcTimes> getGcTimes() {
Map<String, GcTimes> map = Maps.newHashMap();
List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean gcBean : gcBeans) {
map.put(gcBean.getName(), new GcTimes(gcBean));
}
return map;
}
use of java.lang.management.GarbageCollectorMXBean in project flink by apache.
the class TaskExecutorMetricsInitializer method instantiateGarbageCollectorMetrics.
private static void instantiateGarbageCollectorMetrics(MetricGroup metrics) {
List<GarbageCollectorMXBean> garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans();
for (final GarbageCollectorMXBean garbageCollector : garbageCollectors) {
MetricGroup gcGroup = metrics.addGroup(garbageCollector.getName());
gcGroup.<Long, Gauge<Long>>gauge("Count", new Gauge<Long>() {
@Override
public Long getValue() {
return garbageCollector.getCollectionCount();
}
});
gcGroup.<Long, Gauge<Long>>gauge("Time", new Gauge<Long>() {
@Override
public Long getValue() {
return garbageCollector.getCollectionTime();
}
});
}
}
use of java.lang.management.GarbageCollectorMXBean in project flink by apache.
the class MemoryLogger method getGarbageCollectorStatsAsString.
/**
* Gets the garbage collection statistics from the JVM.
*
* @param gcMXBeans The collection of garbage collector beans.
* @return A string denoting the number of times and total elapsed time in garbage collection.
*/
public static String getGarbageCollectorStatsAsString(List<GarbageCollectorMXBean> gcMXBeans) {
StringBuilder bld = new StringBuilder("Garbage collector stats: ");
for (GarbageCollectorMXBean bean : gcMXBeans) {
bld.append('[').append(bean.getName()).append(", GC TIME (ms): ").append(bean.getCollectionTime());
bld.append(", GC COUNT: ").append(bean.getCollectionCount()).append(']');
bld.append(", ");
}
if (!gcMXBeans.isEmpty()) {
bld.setLength(bld.length() - 2);
}
return bld.toString();
}
Aggregations