in analysis/gc-log/src/main/java/org/eclipse/jifa/gclog/model/GCModel.java [635:677]
private void calculateEventsMemoryInfo() {
for (GCEvent event : gcEvents) {
calculateEventMemoryItems(event);
}
gcCollectionEvents.sort(Comparator.comparingDouble(GCEvent::getStartTime));
long lastTotalMemory = 0;
for (GCEvent event : gcCollectionEvents) {
GCMemoryItem young = event.getMemoryItem(YOUNG);
GCMemoryItem total = event.getMemoryItem(HEAP);
GCMemoryItem humongous = event.getMemoryItem(HUMONGOUS);
// reclamation
// sometimes it may have been calculated during parsing log
if (event.getReclamation() == Constant.UNKNOWN_INT && total != null &&
total.getPreUsed() != Constant.UNKNOWN_INT && total.getPostUsed() != Constant.UNKNOWN_INT) {
event.setReclamation(zeroIfNegative(total.getPreUsed() - total.getPostUsed()));
}
// promotion
if (event.getPromotion() == Constant.UNKNOWN_INT
&& event.hasPromotion() && event.getEventType() != G1_MIXED_GC
&& young != null && total != null) {
// notice: g1 young mixed gc should have promotion, but we have no way to know it exactly
long youngReduction = young.getMemoryReduction();
long totalReduction = total.getMemoryReduction();
if (youngReduction != Constant.UNKNOWN_INT && totalReduction != Constant.UNKNOWN_INT) {
long promotion = youngReduction - totalReduction;
if (humongous != null && humongous.getMemoryReduction() != Constant.UNKNOWN_INT) {
promotion += humongous.getMemoryReduction();
}
event.setPromotion(zeroIfNegative(promotion));
}
}
// allocation
if (event.getAllocation() == Constant.UNKNOWN_INT &&
total != null && total.getPreUsed() != Constant.UNKNOWN_INT) {
// As to concurrent event, allocation is composed of two parts: allocation between two adjacent events
// and during event. If original allocation is not unknown, that value is allocation during event.
event.setAllocation(zeroIfNegative(
zeroIfUnknownInt(event.getAllocation()) + total.getPreUsed() - lastTotalMemory));
lastTotalMemory = total.getPostUsed();
}
}
}