java Wildfly 10 内存泄漏问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38874940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 03:51:39  来源:igfitidea点击:

Wildfly 10 Memory Leak Issue

javamemory-leaksgarbage-collectionwildfly-10

提问by kirti

I am using wildfly 10.0.0 Final version. I get java.lang.OutOfMemoryError: GC overhead limit exceeded errorwhenever i undeploy/deploy modules 9-10 times also the memory usage of wildfly keeps on increasing slowly and never decreases and it again gives java.lang.OutOfMemoryError: GC overhead limit exceeded error.

我使用的是wildfly 10.0.0 最终版。我得到java.lang.OutOfMemoryError: GC overhead limit exceeded error每当我取消部署/部署模块9-10倍也wildfly的内存使用量不断增长缓慢和不减少,并再次使java.lang.OutOfMemoryError: GC overhead limit exceeded error.

Wildfly is not releasing the memory after undeployment of application and keeps on increasing on deployment and thus it leads to GC overhead

Wildfly 在取消部署应用程序后不释放内存,并在部署时不断增加,从而导致 GC 开销

Earlier when i was using wildfly 9 version it didnt gave that problem.

早些时候,当我使用 wildfly 9 版本时,它没有出现这个问题。

I tried the fix given in the below link by replacing the core, servlet and websocket modules with the latest release but it didnt worked for me.

我通过用最新版本替换核心、servlet 和 websocket 模块来尝试以下链接中给出的修复,但它对我不起作用。

https://developer.jboss.org/message/959286

Can anyone tell me how to resolve this issue.

谁能告诉我如何解决这个问题。

回答by SkyWalker

You have to increase your heap memory. For this

您必须增加堆内存。为了这

Edit bin/standalone.confconfiguration file, look for the first occurrence of JAVA_OPTS.

编辑bin/standalone.conf配置文件,查找第一次出现的JAVA_OPTS.

Then change the -Xmxoption as you need.

然后-Xmx根据需要更改选项。

If you use Java 8, then

如果您使用 Java 8,那么

Change:

改变:

JAVA_OPTS=”-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true”

To:

到:

JAVA_OPTS=”-Xms64m -Xmx2G -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=2G -Djava.net.preferIPv4Stack=true”

Resource Link:

资源链接:

WildFly 10 — java.lang.OutOfMemoryError: Metadata space

WildFly 10 — java.lang.OutOfMemoryError:元数据空间

UPDATE: Classes not unloaded after undeployment

更新:取消部署后未卸载的类

Martin kouba stated below

马丁·库巴如下所述

  1. undeploy does not necessarily mean class unloading - it depends on JVM settings (-XX:MaxMetaspaceSize and friends for Java8)
  2. I've verified that after 50 deploy/undeploy cycles of the attached reproducer (and using -XX:MaxMetaspaceSize=128m):
  1. undeploy 并不一定意味着类卸载 - 它取决于 JVM 设置(-XX:MaxMetaspaceSize 和 Java8 的朋友)
  2. 我已经验证在附加复制器的 50 个部署/取消部署周期后(并使用 -XX:MaxMetaspaceSize=128m):

for WildFly 10.0.0.Final "java.lang.OutOfMemoryError: Metaspace" occurs

for WildFly 10.1.0-SNAPSHOT (fix for WFLY-6347merged) no OOM error occurs (metaspace is garbage collected)

对于 WildFly 10.0.0.Final "java.lang.OutOfMemoryError: Metaspace" 发生

对于 WildFly 10.1.0-SNAPSHOT(修复WFLY-6347合并)不会发生 OOM 错误(元空间被垃圾收集)

After examining the heap dump I've identified the org.jboss.el.cache.BeanPropertiesCacheas the root cause. In this case, it keeps a hard reference to the person.joey.test.TestClientBeanclass, thus effectively blocking the relevant ModuleClassLoader from GC.

在检查了堆转储后,我确定 org.jboss.el.cache.BeanPropertiesCache了根本原因。在这种情况下,它保持对person.joey.test.TestClientBean类的硬引用,从而有效地阻止了相关的 ModuleClassLoader 来自 GC。

Enum values are treated similarly to static constants - i.e. it's not garbage collected unless the class loader of the owner class is.

枚举值的处理方式与静态常量类似——也就是说,除非所有者类的类加载器是垃圾收集器,否则它不会被垃圾收集。

That's why person.joey.test.RequestTypevalues remain in memory. OmniFaces only amplifies the impact - as mentioned above, it holds a reference to a BeanManager.

这就是person.joey.test.RequestType值保留在内存中的原因。OmniFaces 只会放大影响——如上所述,它持有对 BeanManager 的引用。