2017-04-08 40 views
4

我有一個我正在部署到Jboss EAP 6.1的EAR項目。我的Maven構建的產品是這樣的:JBoss EAP 6.1上的熱交換代理 - java.lang.OutOfMemoryError:PermGen空間

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'. 

的問題當我將耳朵部署到jboss中時,它大約需要10倍的正常時間,當我嘗試從瀏覽器訪問應用程序時,它會拋出「PermGen空間:java.lang.OutOfMemoryError:PermGen空間」。我厭倦了將我的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上配置hotswap-agent進行耳朵部署的正確方法是什麼?

回答

3

終於在hotswap-agent forumVladimir的幫助下在我的項目中獲得了hotswap-agent的工作。這是什麼,他說,幫助解決失控PermGen的記憶:當我刪除了從罐子裏不需要的插件,我可以開始合理的時間和PermGen的內存中的JBoss

JBossAS has single classLoader for each module like jar, war etc. On that account there can be a lot of module classloaders in the running JbossAS. Alongside HotswapAgent copies it's classes to each of that module classloaders (it is necessary otherwise HotswapAgent doesn't work inside module classloader). Hence the same HotswapAgent's class can be loaded by JVM multiple times ! As far as the copying of globaly disabled plugin, it is bug, we should fix it. You can just remove unused plugins directly from hotswap-agent.jar as a workaround, it should help with performance.