You can set the size of the allocated class metadata space that will trigger the first run of GC:
-XX:MetaspaceSize =size[unit], where size is the desired amount of memory for class metadata, and unit denotes the unit in which the is to be initialized. Units can be marked as ‘g' for GB, ‘m' for MB and ‘k' for KB.
To set the memory size for class metadata to 1GB:
Java classes have an internal representation within Java Hotspot VM and are referred to as class metadata. Prior Java 8, the class metadata was allocated in the so-called permanent generation. Since JDK 8, the permanent generation was removed and the class metadata is allocated in native memory. The amount of native memory that can be used for class metadata is by default unlimited. Use the option -XX:MaxMetaspaceSize to put an upper limit on the amount of native memory used for class metadata. To set the size of the allocated class metadata space that will trigger a garbage collection the first time it is exceeded we can use the -XX:MetaspaceSize This threshold for a garbage collection is increased or decreased depending on the amount of metadata used.
The default size depends on the platform.
TODO link UseG1GC, MinHeapFreeRatio, MaxHeapFreeRatio, Xmx, Xms, UseSerialGC, USeParNewGC, UseParallelGC, UseZGC, MaxMetaspaceSize
- Garbage collection tuning
- Garbage collectors documentation
- Quick start on Java GC
- Java hotspot VM GC tuning
If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your insights will help the entire 10+ million java developer community to develop one standard source of documentation for all the JVM arguments.
Edit your Comment