在JBoss EAP 6.1上使用Hotswap-agent出现java.lang.OutOfMemoryError:PermGen空间错误。

4

我有一个EAR项目,要部署到Jboss EAP 6.1。我的Maven构建生成的产品如下:

myapp-ear
├── myapp-ejb.jar
├── myapp-web.war
├── lib
│   ├── activation.jar
│   ├── activiti-bpmn-converter.jar
│   ├── activiti-bpmn-model.jar
.....
│   ├── xml-apis.jar
│   └── xmlbeans.jar
└── META-INF
    ├── application.xml
    ├── hotswap-agent.properties
    ├── myapp-ds.xml
    ├── jboss-deployment-structure.xml
    └── MANIFEST.MF

当我部署我的应用程序时,以下是我在 JBoss 日志中得到的内容:

21:34:55,570 INFO  [stdout] (MSC service thread 1-5) HOTSWAP AGENT: 21:34:55.569 INFO (org.hotswap.agent.config.PluginRegistry) - Plugin 'org.hotswap.agent.plugin.jbossmodules.JBossModulesPlugin' initialized in ClassLoader 'ModuleClassLoader for Module "deployment.myapp-ds.xml:main" from Service Module Loader'.
21:35:04,357 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "null" (runtime-name: "myapp-web.war")
21:35:04,357 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "null" (runtime-name: "myapp-ejb.jar")
21:35:04,781 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011401: Read persistence.xml for myproject
21:35:05,306 INFO  [stdout] (MSC service thread 1-7) HOTSWAP AGENT: 21:35:05.306 INFO (org.hotswap.agent.config.PluginRegistry) - Plugin 'org.hotswap.agent.plugin.jbossmodules.JBossModulesPlugin' initialized in ClassLoader 'ModuleClassLoader for Module "deployment.myapp-ear.ear:main" from Service Module Loader'.

并且

21:35:05,488 INFO  [stdout] (MSC service thread 1-6) HOTSWAP AGENT: 21:35:05.487 INFO (org.hotswap.agent.config.PluginRegistry) - Plugin 'org.hotswap.agent.plugin.hotswapper.HotswapperPlugin' initialized in ClassLoader 'ModuleClassLoader for Module "deployment.myapp-ear.ear.myapp-web.war:main" from Service Module Loader'.
21:35:05,520 INFO  [stdout] (MSC service thread 1-4) HOTSWAP AGENT: 21:35:05.517 INFO (org.hotswap.agent.config.PluginRegistry) - Plugin 'org.hotswap.agent.plugin.jbossmodules.JBossModulesPlugin' initialized in ClassLoader 'ModuleClassLoader for Module "deployment.myapp-ear.ear.myapp-ejb.jar:main" from Service Module Loader'.

问题在于,当我将我的ear部署到jboss时,它需要大约10倍的时间,而且当我尝试从浏览器访问应用程序时,会抛出“PermGen space:java.lang.OutOfMemoryError:PermGen space”错误。 我尝试增加我的PermGen内存到700MB,但没有成功。 因此,我怀疑hotswap-agent正在监视EAR中的所有类,包括lib目录中的类,这导致它消耗了太多的内存。

我接下来查看的地方是通过在hotswap-agent.properties中放置autoHotswap=false来默认禁用热交换。 我已经尝试将此文件放置在EAR中以及EJB和WAR类路径中,但并没有什么区别。 我还尝试过往JVM_OPTS中添加此属性,但也没有成功:

-javaagent:/workspace/tools/hotswap-agent-1.0.jar=disablePlugin=Deltaspike,disablePlugin=JavaBeans,autoHotswap=false"

我的问题是,如何控制环境中的热替换代理?还有只监视指定包中的类,比如“com.foobar”的方法吗?最后,如何在jboss上为ear部署正确配置热替换代理。

1个回答

3
最后在hotswap-agent论坛上向Vladimir求助后,成功地将hotswap-agent应用到我的IT项目中。他提供了以下解决PermGen内存泄漏的方式:

JBossAS为每个模块(例如jar、war等)都有单独的类加载器。因此,在运行中的JbossAS中可能会有很多模块类加载器。同时,HotswapAgent会将它自己的类复制到每个模块类加载器中(否则HotswapAgent无法在模块类加载器中工作)。因此,同一个HotswapAgent类可能被JVM多次加载!至于全局禁用插件的复制问题,这是一个bug,我们应该修复它。你可以直接从hotswap-agent.jar中删除未使用的插件,作为解决方案,这应该有助于提高性能。

一旦我从jar文件中删除了不需要的插件,就可以在合理的时间内启动jboss并解决PermGen内存泄漏问题了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接