2013-03-22 101 views
1

我有一個Grails應用程序,我用戰爭命令打包了:grails war。我需要將它部署到運行Tomcat的遠程機器上。Grails Tomcat OutofMemory錯誤

當我執行卸載部署(將WAR文件複製到C:\Program Files (x86)\apache-tomcat-7.0.37\webapps)並運行C:\Program Files (x86)\apache-tomcat-7.0.37\bin\startup.bat時,我得到了幾個與PermGem和Heap空間有關的OutofMemory錯誤。

我該如何解決這個問題?

回答

4

起tomcat的時候我最常做的:

export JAVA_OPTS="-Xms1024m -Xmx2024m -XX:MaxPermSize=512m"; export CATALINA_OPTS="-Xms1024m -Xmx2024m -XX:MaxPermSize=512m"; /etc/init.d/tomcat6 restart; tail -f /var/lib/tomcat6/logs/catalina.out 

這正好解決所有內存問題。我有6個使用該配置運行的Grails應用程序。

+0

如果以完全相同的方式指定JAVA_OPTS(CATALINA_OPTS僅用於「start」命令的JAVA_OPTS),則不需要設置CATALINA_OPTS。 – 2013-03-22 17:05:52

+0

,你從命令行調用這個? – 2013-03-22 18:39:26

+0

是從命令行。如果你不使用ubuntu,路徑/etc/init.d/tomcat6可能會有所不同。 – 2013-03-23 21:01:24

2

在Tomcat服務器,添加系統環境變量:JAVA_OPTS -Xmx512m

此外,在conf你的Grails應用程序/ BuildConfig.groovy在下面一行添加行頂部: grails.tomcat .jvmArgs = [「-Xms256m」,「-Xmx1024m」,「-XX:PermSize = 512m」,「-XX:MaxPermSize = 512m」]

這似乎解決了我面對的許多問題。

0

如果你使用的是Ubuntu,我建議編輯/ etc/default/tomcat6(或tomcat7取決於你正在運行的)。

第20行是示例JAVA_OPTS行;取消註釋,並對其進行編輯以適合您的硬件。

我有我的一樣運行:

JAVA_OPTS="-Djava.awt.headless=true -Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC" 

其中帽在使用RAM的演出,並設置permsize到512M。

0

使用在這一點上的Grails Build.config 更改默認值:

grails.project.fork = [ 
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required 
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true], 

// configure settings for the test-app JVM, uses the daemon by default 
test: [maxMemory: 768, minMemory: 64, debug: true, maxPerm: 256, daemon:true], 
// configure settings for the run-app JVM 
run: [maxMemory: 500, minMemory: 64, debug: true, maxPerm: 256, forkReserve:false], 
// configure settings for the run-war JVM 
war: [maxMemory: 500, minMemory: 64, debug: true, maxPerm: 256, forkReserve:false], 
// configure settings for the Console UI JVM 
console: [maxMemory: 500, minMemory: 64, debug: true, maxPerm: 256] 

]

0

,如果你使用的是基於服務的Tomcat,那麼你可能沒有catalina.bat中的bin文件夾中的文件。 然後嘗試添加這些java選項。 enter image description here