From reading a rather mature Oracle blog entry, I learned that
(...) the permanent generation is currently collected serially.
However, this blog entry is from quite some years ago and I was wondering how the recent advancements in garbage collection algorithms might have changed the accuracy of this statement. I am especially wondering about the new G1 garbage collector which is desribed by Oracle with:
The older garbage collectors (serial, parallel, CMS) all structure the heap into three sections: young generation, old generation, and permanent generation of a fixed memory size. (...) When performing garbage collections, G1 operates in a manner similar to the CMS collector.
but never mentions the permanent generation in the entire tutorial again.
From reading about CMS - which according to the above statement works similar to G1 - I did not find any explicit information on the permanent generation either but learned from this other blog entry that
(...) the Concurrent Mark and Sweep does not compact at all. Once objects cannot be allocated anymore a serial major GC is triggered.
So I am wondering if modern garbage collectors, such as CMS or G1, just completely ignore the permanent generation and leave it to full GC invocations which run the old serial GC to clean out the permanent generation (while this serial GC also collects the young and mature generations serially which I would not understand to be desirable when G1 was used instead of CMS). I am mainly interested in finding out if it is more expensive in terms of STW and collection time to perform garbage collection on the permanent generation than it is to collection the tenured generation.
Bonus question: The Oracle tutorial mentions that the permanent generation is part of the heap. I always thought that the permanant generation was explicitly allocated outside of the heap. Did this change in recent HotSpot implementations?
Thank you for your help!
Young Generation. Most newly allocated objects are allocated in the young generation (see Figure 1), which is typically small and collected frequently.
Permanent Generation It is populated by the JVM at runtime based on classes in use by the application. Classes that are no longer in use may be garbage collected from the Permanent Generation.
Parallel GC As the name implies, it uses multiple VM threads to perform the garbage collection. It also executes in a stop-the-world fashion. Applications that require a high rate of throughput can benefit from this GC.
The PermGen is garbage collected like the other parts of the heap. The thing to note here is that the PermGen contains meta-data of the classes and the objects i.e. pointers into the rest of the heap where the objects are allocated.
There is a JEP156 about making G1 able to unload classes without a full GC, but the dependences section states that it makes sense to wait with [JEP122] until the permanent generation is gone to make JEP156 easier to implement.
So it looks like that this problem may indeed be solved in Java 8, but not just thanks to the meta space, instead because meta space is taken as a pre-requisite to do incremental GC of classes.
That's my understanding.
edit: Over the past few days I've been listening to some of this year's JavaOne sessions and quite luckily I found one just today about PermGen removal that says it all:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With