英文:
Wildfly 16 : What is benefit of changing XX:MaxMetaspaceSize in Java8?
问题
我在Wildfly中遇到了Metaspace问题。
目前XX:MaxMetaspaceSize设置为256M。但是在不同的项目(总共分布在多个服务器组中的50个项目中),我多次遇到了以下问题,并且每天都面临以下异常:
定义类失败:OutOfMemoryException:Metaspace
大多数帖子(包括stackoverflow等)建议在Wildfly的情况下应该设置为2GB。
但我在各种文章中读到,Java 8中不需要增加Metaspace:
在Java 8中,保存类的Metaspace默认情况下可以无限扩展。
请解决这个困惑 - 如果Metaspace会自动增加,假设我设置为256,那么它是否不会自动增加?在2G上会有什么好处?
英文:
I am getting metaspace issue in Wildfly.
Currently XX:MaxMetaspaceSize is 256M. But i am getting following issue multiple times in multiple server groups in different projects (50 projects in total distributed among server groups). And facing following exception daily.
failed to define class: OutOfMemoryException: Metaspace
Most of posts(stackoverflow and others) suggest it should be 2GB in case of wildfly.
But i have read in various article which suggests that in Java 8 there is no need to increasing Metaspace:
In Java 8, the metaspace that holds your classes can expand without limit by default,
Could you please resolve this confusion that - if Metaspace is automatically increased and suppose i have set 256 then does it not automatically increase? What benefit i will get at 2G.
答案1
得分: 1
根据Oracle文档,在Java 8中,类元数据存储在本机内存中,默认情况下是无限制的。 MaxMetaspaceSize
对用于类元数据的本机内存使用设置了上限。
如果您还启用了 UseCompressedOops
和 UseCompressedClassesPointers
,那么 MaxMetaspaceSize
将设置对类元数据的两个本机内存区域的总和的上限 - 用于压缩类元数据的区域以及用于所有其他类元数据的区域。
另外,2GB听起来有点高。我建议逐渐增加并进行测试,以确保您将其设置为最适合您需求的值。
英文:
Per the Oracle docs, in Java 8, the class metadata is stored in native memory and by default is unlimited. MaxMetaspaceSize
puts an upper limit on the native memory that's used for class metadata.
If you also have UseCompressedOops
and UseCompressedClassesPointers
enabled, then MaxMetaspaceSize
sets the upper limit on the sum of both areas of native memory used for class metadata - the area for the compressed class metadata, and the area for all other class metadata.
Also, 2GB sounds a bit high. I would slowly increase and test to be sure you're setting this to an optimal value for your needs.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论