We created a sample Java program in order to load the Java Heap and trigger an explicit GC in order to generate some interesting verbose GC output. This program is simply loading about 3 million instances of java.lang.String in a static Map data structure and triggers an explicit GC (via System.gc()) followed by the removal of 2 million instances along with a second explicit GC before exiting.

As you can see from the verbose GC output, the OldGen space was at 340 MB after the initial loading of 3 M String instances in our HashMap. It did go down to 126 MB following the removal of 2 M String instances.

Now find below explanation and snapshots on how you can read the GC output data in more detail for each Java Heap space.

## YoungGen space analysis

## OldGen space analysis

## PermGen space analysis

## Java Heap breakdown analysis

Conclusion

I hope this sample Java program and verbose GC output analysis has helped you understand how to read and interpret this critical data. Please do not hesitate to post any comment or question. My next article will cover the verbose GC for the IBM Java JRE.

I don't think Windows 7 is mandatory, you can run it on any machine. key point is to understand GC logs, which I guess most important if you are serious on How your application is performing. understanding of GC logs are also getting popular on Interviews. Some of them I have shared on my post 10 Garbage Collection Interview Questions. Once again Congrats to P-H for coming with such a nice article.

Hi P-H, Very good article to understanding this complex subject. I ran the same program on Windows 7, 64-bit with Java 1.7.0_25. Saw some difference in output - instead of PSOldGen like your output, I see ParOldGen from mine. I used same VM params as you. Can you explain what is the difference and why?Thanks!-Vijay

Hi P-H, I see that the collector in GC log does correspond to +UseParallelOldGC. But I did not turn this option on. Used exactly same options as you. Maybe in recent JREs (in combination with machine environment) that seems to be the default.

Another question - looking at your first Full GC output - PSOldGen: 296856K->340433K. It appears that Before space is smaller than After. What does it mean.. there was no space freed.. but instead more objects were added to Old gen? Thanks.