设置MetaspaceSize的准则-Java 8 [英] Guidelines to set MetaspaceSize - java 8

查看:768
本文介绍了设置MetaspaceSize的准则-Java 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

64位服务器的MetaspaceSize的默认值是什么?我在官方文档中找不到它.

What is the default value of MetaspaceSize for 64-bit servers? I couldn't find it in the official documentation.

我观察到,在服务器JVM进程中,GC频率有时会很高并且持续增长.如果我重新启动该服务几次,它将恢复稳定.我认为这是由于JRE升级所致.

I'm observing that in a server JVM process, at times, the GC frequency becomes high and keeps growing. If I restart the service a few times, it returns to stable. I think its due to the JRE upgrade.

JVM堆最大大小设置为6GB,但是当发生此问题时,我们看到仅使用3GB堆.元空间几乎没有增长,并且几乎总是充满.我尝试将元空间增加到1GB,这样可以提高吞吐量.

JVM Heap max size is set to be 6GB but when this problem occurs, we see only 3GB heap being used. Metaspace grows by very little and is almost always full. I tried increasing the metaspace to 1GB and it improves the throughput.

我认为正在发生的事情是,默认情况下,Metaspace设置为非常低的值,因此GC起作用了.每次发生GC时,高水位线都会不断增加(再次是非常低的量).

I think what is happening is Metaspace by default is set to a very low value and thus GC kicks in. High water mark is continuously increased(again by a very low amount) every time a GC occurs.

我想设置MetaspaceSize(不确定当前值是多少).

I want to set the MetaspaceSize (not sure what is the current value).

Oracle文档说,没有指南可以知道将MetaspaceSize设置为什么.但是有没有办法找出将其设置为正确的值呢?

Oracle docs say there are no guidelines to know what to set MetaspaceSize to. But is there a way to find out what would be the correct value to set it to?

我从Oracle文档中得到的一个提示是:

One hint I got from Oracle docs is this:

If the committed space available for class metadata as a percentage of the total committed space for class metadata is greater than MaxMetaspaceFreeRatio, then the high-water mark will be lowered. If it is less than MinMetaspaceFreeRatio, then the high-water mark will be raised.

但是仍然无法弄清楚如何稳定GC..我有三个问题:

But still not able to figure out how to stabilize the GCs..I have three questions:

  1. 64位服务器上的默认MetaspaceSize是什么?
  2. 默认比率是什么:MaxMetaspaceFreeRatio,MinMetaspaceFreeRatio设置为?答:它显示最小为40,最大为70
  3. 如何确定Metaspacesize值?

推荐答案

MetaspaceSize是触发Full GC时的值,它的不是初始空间或最大空间.

MetaspaceSize is the value when a Full GC will be triggered, its not initial space nor maximum space.

它的默认值是20MB(至少在jdk-8jdk-13上):

The default value for it is 20MB (at least on jdk-8 to jdk-13):

java -XX:+PrintFlagsFinal -version | grep MetaspaceSize

将产生:

size_t MetaspaceSize = 21807104 // 20MB

这意味着,当Metaspace到达20MB时,将触发Full GC,如果可以避免的话,那会很好.

This means that when Metaspace reaches 20MB a Full GC will be triggered and if you can avoid it, that would be good.

考虑到潜在的数据元空间可以容纳多少(方法,注释等),在我看来20MB最初是一个很小的值.不幸的是,选择正确的值并不容易.

Considering how much data metaspace can potentially hold (methods, annotations, etc), it seems to me that 20MB is a very small value to start with. Unfortunately, choosing a correct value is not easy.

您有两个选择,启用gc日志记录-Xlog:gc并让该应用程序运行一段时间,然后找到类似以下的实例:

You have two options, enable gc logging -Xlog:gc and let the app run for some time and then find instances like:

[Full GC (Metadata GC Threshold) ...]

并从中了解您需要设置什么以及如何设置.

And understand from these what you need to set and how.

通过以下方式开始该过程:

Or start the process with:

java -XX:NativeMemoryTracking=detail

通过:

jcmd <YourJVMPID> VM.metaspace

找到这样的行:

 Virtual space:
    Non-class space:        8.00 MB reserved,       4.25 MB ( 53%) committed
    Class space:            1.00 GB reserved,     512.00 KB ( <1%) committed
    Both:                   1.01 GB reserved,       4.75 MB ( <1%) committed

在应用程序运行至少一天IMHO之后,从Non-class space获取值.

And get the value from Non-class space after the app has been running for at least a day IMHO.

关于如何控制Metaspace的其他各种设置,您可以像这样找到:

There are various other settings on how to control Metaspace, which you can find out like this:

java -XX:+PrintFlagsFinal -version | grep Metaspace

这篇关于设置MetaspaceSize的准则-Java 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆