Repository: microsoft/gctoolkit
File: parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java (Java)

Code before:
//            forwardReference.setHeapSizeBeforeCollection(trace.getLongGroup(1));
//        } else {
//            forwardReference.setHeapOccupancyAfterCollection(trace.getLongGroup(2));
//            forwardReference.setHeapSizeAfterCollection(trace.getLongGroup(1));
//        }
    }

    //Minimum heap 8388608  Initial heap 268435456  Maximum heap 268435456
    //these values go back to the JavaVirtualMachine..
    public void heapSize(GCLogTrace trace, String line) {
        G1GCForwardReference.setMinHeapSize(trace.getLongGroup(1));
        G1GCForwardReference.setInitialHeapSize(trace.getLongGroup(2));
        G1GCForwardReference.setMaxHeapSize(trace.getLongGroup(3));
    }

    //return to JVM
    private int regionSize = 0; //region size in Gigabytes

    public void heapRegionSize(GCLogTrace trace, String line) {
        regionSize = trace.getIntegerGroup(1);
    }

    //[15.316s][debug][gc,heap      ] GC(0)   region size 1024K, 24 young (24576K), 0 survivors (0K)
    //ignore this logging for now
    private void youngRegionAllotment(GCLogTrace trace, String line) {
        regionSize = trace.getIntegerGroup(1) / 1024;
        if (before) {
            forwardReference.setYoungOccupancyBeforeCollection(trace.getLongGroup(3));
            forwardReference.setSurvivorOccupancyBeforeCollection(trace.getLongGroup(5));
            forwardReference.setEdenOccupancyBeforeCollection(trace.getLongGroup(3)-trace.getLongGroup(5));
            forwardReference.setYoungSizeBeforeCollection(trace.getLongGroup(3));
        }
        else {
            forwardReference.setYoungOccupancyAfterCollection(trace.getLongGroup(5));
            forwardReference.setSurvivorOccupancyAfterCollection(trace.getLongGroup(5));
            forwardReference.setEdenOccupancyAfterCollection(0L);
            forwardReference.setYoungSizeAfterCollection(trace.getLongGroup(3));
        }
    }

    /**
     * @param trace
     * @param line
     */
    private void metaClassSpace(GCLogTrace trace, String line) {
        if (before) {
            if (trace.getGroup(1).equals("Metaspace")) {
                forwardReference.setMetaspaceOccupancyBeforeCollection(trace.getLongGroup(2));
                forwardReference.setMetaspaceSizeBeforeCollection(trace.getLongGroup(3));
                forwardReference.setMetaspaceCommittedBeforeCollection(trace.getLongGroup(4));
                forwardReference.setMetaspaceReservedBeforeCollection(trace.getLongGroup(5));

Review comment (suggestion):
I'd rather see forwardReference.setHeapRegionSize called here, even if the value doesn't change. I don't like that heapRegionSize gets treated differently as it makes code maintenance more difficult. Much easier to find where setHeapRegionSize is called, for example.

Code after:
    //Ignore these log messages for now.
    private void heapSummary(GCLogTrace trace, String line) {
//        if ( before) {
//            forwardReference.setHeapOccupancyBeforeCollection(trace.getLongGroup(2));
//            forwardReference.setHeapSizeBeforeCollection(trace.getLongGroup(1));
//        } else {
//            forwardReference.setHeapOccupancyAfterCollection(trace.getLongGroup(2));
//            forwardReference.setHeapSizeAfterCollection(trace.getLongGroup(1));
//        }
    }

    //Minimum heap 8388608  Initial heap 268435456  Maximum heap 268435456
    //these values go back to the JavaVirtualMachine..
    public void heapSize(GCLogTrace trace, String line) {
        this.minHeapSize = trace.getLongGroup(1);
        this.initialHeapSize = trace.getLongGroup(2);
        this.maxHeapSize = trace.getLongGroup(3);
    }

    //return to JVM
    private int regionSize = 0; //region size in Gigabytes
    private long minHeapSize = 0;
    private long initialHeapSize = 0;
    private long maxHeapSize = 0;

    public void heapRegionSize(GCLogTrace trace, String line) {
        regionSize = trace.getIntegerGroup(1);
    }

    //[15.316s][debug][gc,heap      ] GC(0)   region size 1024K, 24 young (24576K), 0 survivors (0K)
    //ignore this logging for now
    private void youngRegionAllotment(GCLogTrace trace, String line) {
        forwardReference.setHeapRegionSize(trace.getIntegerGroup(1) / 1024);
        if (before) {
            forwardReference.setYoungOccupancyBeforeCollection(trace.getLongGroup(3));
            forwardReference.setSurvivorOccupancyBeforeCollection(trace.getLongGroup(5));
            forwardReference.setEdenOccupancyBeforeCollection(trace.getLongGroup(3)-trace.getLongGroup(5));
            forwardReference.setYoungSizeBeforeCollection(trace.getLongGroup(3));
        }
        else {
            forwardReference.setYoungOccupancyAfterCollection(trace.getLongGroup(5));
            forwardReference.setSurvivorOccupancyAfterCollection(trace.getLongGroup(5));
            forwardReference.setEdenOccupancyAfterCollection(0L);
            forwardReference.setYoungSizeAfterCollection(trace.getLongGroup(3));
        }
    }

    /**
     * @param trace
     * @param line
     */