Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
528 views
in Technique[技术] by (71.8m points)

java - What is the Metadata GC Threshold and how do I tune it?

In an application I have the following -verbose:gc

[GC (Metadata GC Threshold)  8530310K->2065630K(31574016K), 0.3831399 secs]
[Full GC (Metadata GC Threshold)  2065630K->2053217K(31574016K), 3.5927870 secs]
[GC (Metadata GC Threshold)  8061486K->2076192K(31574016K), 0.0096316 secs]
[Full GC (Metadata GC Threshold)  2076192K->2055722K(31574016K), 0.9376524 secs]
[GC (Metadata GC Threshold)  8765230K->2100440K(31574016K), 0.0150190 secs]
[Full GC (Metadata GC Threshold)  2100440K->2077052K(31574016K), 4.1662779 secs]

What is this "Metadata GC threshold" and how to I reduce it. Note: while the Full GC spends a long time cleaning up, it does not actually clean up much, i.e. it would be better if it didn't do this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The log message tells that GC was caused by Metaspace allocation failure. Metaspaces hold class metadata. They have appeared in Java?8 to replace PermGen.

Here are some options to tune Metaspaces.
You may want to set one or several of the following options:

-XX:MetaspaceSize=100M Sets the size of the allocated class metadata space that will trigger a garbage collection the first time it is exceeded;

-XX:InitialBootClassLoaderMetaspaceSize=32M to increase the boot class loader Metaspace;

-XX:MinMetaspaceFreeRatio=50 to make Metaspaces grow more agressively;

-XX:MaxMetaspaceFreeRatio=80 to reduce the chance of Metaspaces shrinking;

-XX:MinMetaspaceExpansion=4M the minumum size by which a Metaspace is exanded;

-XX:MaxMetaspaceExpansion=16M the maximum size to expand a Metaspace by without Full?GC.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...