Skip to content

Commit 58442cf

Browse files
committed
Move non-detailed memory check into separate method per feedback.
1 parent e36fd81 commit 58442cf

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

parser/src/main/java/com/microsoft/gctoolkit/parser/ZGCParser.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -572,20 +572,9 @@ private void memorySummary(GCLogTrace trace, String s) {
572572
gcCauseMap.remove(gcId);
573573
}
574574

575-
// We use the lack of a MemorySummary in the forwardReference as a sign that this is the case and
576-
// that we need to publish a Generational no-details event.
577-
ZGCCycleType type = ZGCCycleType.get(trace.getGroup(2));
578-
ZGCForwardReference forwardReference = ZGCCycleType.MAJOR.equals(type) ?
579-
getForwardRefForPhase(ZGCPhase.MAJOR_YOUNG) :
580-
getForwardRefForPhase(ZGCPhase.MINOR_YOUNG);
581-
582-
if (forwardReference != null && !forwardReference.hasMemorySummary()) {
583-
forwardReference.setMemorySummary(
584-
new ZGCMemorySummary(
585-
trace.toKBytes(4),
586-
trace.toKBytes(7)));
587-
publish(forwardReference.getGCEVent(getClock()));
588-
}
575+
// Publish a non-detailed generational event if present.
576+
publishIfMemorySummaryMissing(trace);
577+
589578
} else {
590579
ZGCForwardReference forwardReference = getForwardRefForPhase(ZGCPhase.FULL);
591580

@@ -607,8 +596,27 @@ private void memorySummary(GCLogTrace trace, String s) {
607596
// TODO - Get rid of this?
608597
Arrays.fill(heapCapacity, 0L);
609598
}
610-
611-
599+
600+
private void publishIfMemorySummaryMissing(GCLogTrace trace) {
601+
if (trace == null)
602+
return;
603+
604+
// We use the lack of a MemorySummary in the forwardReference as a sign
605+
// that we need to publish a Generational no-details event.
606+
ZGCCycleType cycleType = ZGCCycleType.get(trace.getGroup(2));
607+
ZGCForwardReference forwardReference = ZGCCycleType.MAJOR.equals(cycleType) ?
608+
getForwardRefForPhase(ZGCPhase.MAJOR_YOUNG) :
609+
getForwardRefForPhase(ZGCPhase.MINOR_YOUNG);
610+
611+
if (forwardReference != null && !forwardReference.hasMemorySummary()) {
612+
forwardReference.setMemorySummary(
613+
new ZGCMemorySummary(
614+
trace.toKBytes(4),
615+
trace.toKBytes(7)));
616+
publish(forwardReference.getGCEVent(getClock()));
617+
}
618+
}
619+
612620
private void log(String line) {
613621
GCToolKit.LOG_DEBUG_MESSAGE(() -> "ZGCHeapParser missed: " + line);
614622

0 commit comments

Comments
 (0)