/** * Create a new instance. * * @param info * The info object from the notification emitter on the * {@link java.lang.management.GarbageCollectorMXBean}. * @param startTime * Start time in milliseconds since the epoch. Note the info object has a start time relative * to the time the jvm process was started. */ public GcEvent(GarbageCollectionNotificationInfo info, long startTime) { this.name = info.getGcName(); this.info = info; this.type = HelperFunctions.getGcType(name); this.startTime = startTime; }
/** * Create a new instance. * * @param info * The info object from the notification emitter on the * {@link java.lang.management.GarbageCollectorMXBean}. * @param startTime * Start time in milliseconds since the epoch. Note the info object has a start time relative * to the time the jvm process was started. */ public GcEvent(GarbageCollectionNotificationInfo info, long startTime) { this.name = info.getGcName(); this.info = info; this.type = HelperFunctions.getGcType(name); this.startTime = startTime; }
private void updateMetrics(String name, GcInfo info) { final Map<String, MemoryUsage> before = info.getMemoryUsageBeforeGc(); final Map<String, MemoryUsage> after = info.getMemoryUsageAfterGc(); if (oldGenPoolName != null) { final long oldBefore = before.get(oldGenPoolName).getUsed(); final long oldAfter = after.get(oldGenPoolName).getUsed(); final long delta = oldAfter - oldBefore; if (delta > 0L) { PROMOTION_RATE.increment(delta); } // Some GCs such as G1 can reduce the old gen size as part of a minor GC. To track the // live data size we record the value if we see a reduction in the old gen heap size or // after a major GC. if (oldAfter < oldBefore || HelperFunctions.getGcType(name) == GcType.OLD) { LIVE_DATA_SIZE.set(oldAfter); final long oldMaxAfter = after.get(oldGenPoolName).getMax(); MAX_DATA_SIZE.set(oldMaxAfter); } } if (youngGenPoolName != null) { final long youngBefore = before.get(youngGenPoolName).getUsed(); final long youngAfter = after.get(youngGenPoolName).getUsed(); final long delta = youngBefore - youngGenSizeAfter; youngGenSizeAfter = youngAfter; if (delta > 0L) { ALLOCATION_RATE.increment(delta); } } }
private void updateMetrics(String name, GcInfo info) { final Map<String, MemoryUsage> before = info.getMemoryUsageBeforeGc(); final Map<String, MemoryUsage> after = info.getMemoryUsageAfterGc(); if (oldGenPoolName != null) { final long oldBefore = before.get(oldGenPoolName).getUsed(); final long oldAfter = after.get(oldGenPoolName).getUsed(); final long delta = oldAfter - oldBefore; if (delta > 0L) { PROMOTION_RATE.increment(delta); } // Some GCs such as G1 can reduce the old gen size as part of a minor GC. To track the // live data size we record the value if we see a reduction in the old gen heap size or // after a major GC. if (oldAfter < oldBefore || HelperFunctions.getGcType(name) == GcType.OLD) { LIVE_DATA_SIZE.set(oldAfter); final long oldMaxAfter = after.get(oldGenPoolName).getMax(); MAX_DATA_SIZE.set(oldMaxAfter); } } if (youngGenPoolName != null) { final long youngBefore = before.get(youngGenPoolName).getUsed(); final long youngAfter = after.get(youngGenPoolName).getUsed(); final long delta = youngBefore - youngGenSizeAfter; youngGenSizeAfter = youngAfter; if (delta > 0L) { ALLOCATION_RATE.increment(delta); } } }