diff --git a/api/src/main/java/com/microsoft/gctoolkit/event/g1gc/G1GCPauseEvent.java b/api/src/main/java/com/microsoft/gctoolkit/event/g1gc/G1GCPauseEvent.java index 579e991..f344bd3 100644 --- a/api/src/main/java/com/microsoft/gctoolkit/event/g1gc/G1GCPauseEvent.java +++ b/api/src/main/java/com/microsoft/gctoolkit/event/g1gc/G1GCPauseEvent.java @@ -29,6 +29,7 @@ public abstract class G1GCPauseEvent extends G1GCEvent { private RegionSummary archiveRegion; private CPUSummary cpuSummary; + private int heapRegionSize; public G1GCPauseEvent(DateTimeStamp timeStamp, GarbageCollectionTypes type, GCCause cause, double duration) { super(timeStamp, type, cause, duration); @@ -102,10 +103,15 @@ public abstract class G1GCPauseEvent extends G1GCEvent { } else if (getSurvivor() == null) { return getHeap().minus(getEden()); } else { - return new MemoryPoolSummary(getHeap().getOccupancyBeforeCollection() - this.getEden().getOccupancyBeforeCollection() - getSurvivor().getOccupancyBeforeCollection(), - getHeap().getSizeBeforeCollection() - getEden().getSizeBeforeCollection() - getSurvivor().getOccupancyBeforeCollection(), - getHeap().getOccupancyAfterCollection() - getEden().getOccupancyAfterCollection() - getSurvivor().getOccupancyAfterCollection(), - getHeap().getSizeAfterCollection() - getEden().getSizeAfterCollection() - getSurvivor().getOccupancyAfterCollection()); + final RegionSummary summary = getArchiveRegionSummary(); + final long archiveRegionByteBefore = summary.getBefore() * heapRegionSize * 1024L; + final long archiveRegionByteAfter = summary.getAfter() * heapRegionSize * 1024L; + final long archiveRegionByteAssigned = summary.getAssigned() * heapRegionSize * 1024L; + + return new MemoryPoolSummary(getHeap().getOccupancyBeforeCollection() - this.getEden().getOccupancyBeforeCollection() - getSurvivor().getOccupancyBeforeCollection() - archiveRegionByteAssigned, + getHeap().getSizeBeforeCollection() - getEden().getSizeBeforeCollection() - getSurvivor().getOccupancyBeforeCollection() - archiveRegionByteBefore, + getHeap().getOccupancyAfterCollection() - getEden().getOccupancyAfterCollection() - getSurvivor().getOccupancyAfterCollection() - archiveRegionByteAssigned, + getHeap().getSizeAfterCollection() - getEden().getSizeAfterCollection() - getSurvivor().getOccupancyAfterCollection() - archiveRegionByteAfter); } } @@ -121,4 +127,7 @@ public abstract class G1GCPauseEvent extends G1GCEvent { return this.cpuSummary; } + public void addHeapRegionSize(int heapRegionSize) { + this.heapRegionSize = heapRegionSize; + } } diff --git a/parser/src/main/java/com/microsoft/gctoolkit/parser/G1GCForwardReference.java b/parser/src/main/java/com/microsoft/gctoolkit/parser/G1GCForwardReference.java index 699e501..a91b08f 100644 --- a/parser/src/main/java/com/microsoft/gctoolkit/parser/G1GCForwardReference.java +++ b/parser/src/main/java/com/microsoft/gctoolkit/parser/G1GCForwardReference.java @@ -544,6 +544,7 @@ class G1GCForwardReference extends ForwardReference { SurvivorMemoryPoolSummary survivor = getSurvivorMemoryPoolSummary(); MemoryPoolSummary tenured = getMemoryPoolSummary(OLD_OCCUPANCY_BEFORE_COLLECTION); MemoryPoolSummary humongous = getMemoryPoolSummary(HUMONGOUS_OCCUPANCY_BEFORE_COLLECTION); + collection.addHeapRegionSize(heapRegionSize); if (heap != null && eden != null && survivor != null) { collection.addMemorySummary(eden, survivor, heap); } else if (eden == null && survivor == null && heap != null) { diff --git a/parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java b/parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java index adfdcc8..9a75822 100644 --- a/parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java +++ b/parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java @@ -494,6 +494,7 @@ public class UnifiedG1GCParser extends UnifiedGCLogParser implements UnifiedG1GC forwardReference.setHumongousRegionSummary(summary); break; case "Archive": + // Archive Region type is only available in JDK 14 and 17. forwardReference.setArchiveRegionSummary(summary); break; default: