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

前端 未结 2 1934
后悔当初
后悔当初 2020-12-01 00:36

In an application I have the following -verbose:gc

[GC (Metadata GC Threshold)  8530310K->2065630K(31574016K), 0.3831399 secs]
[Full GC (Meta         


        
2条回答
  •  半阙折子戏
    2020-12-01 01:38

    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.

提交回复
热议问题