Java 增加基于 Windows 安装程序的 Tomcat PermGen Space

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21104340/
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-08-13 06:36:28  来源:igfitidea点击:

Increase Windows installer-based Tomcat PermGen Space

javawindowstomcatgrails

提问by Manuel Calles

I'm having some problems with Tomcat. I'm deploying a Grails application and as I were adding new features I got this (sadly well known) error in the stacktrace file:

我在使用 Tomcat 时遇到了一些问题。我正在部署一个 Grails 应用程序,当我添加新功能时,我在堆栈跟踪文件中遇到了这个(可悲的是众所周知的)错误:

Caused by: java.lang.OutOfMemoryError: PermGen space
2014-01-13 19:28:35,753 [http-bio-8080-exec-26] ERROR StackTrace  - Full Stack Trace:
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.OutOfMemoryError: PermGen space
    at gsp_liquidaciones_liquidacionDeComplejolist_gsp$_run_closure2.doCall(gsp_liquidaciones_liquidacionDeComplejolist_gsp.groovy:84)
    at gsp_liquidaciones_liquidacionDeComplejolist_gsp.run(gsp_liquidaciones_liquidacionDeComplejolist_gsp.groovy:105)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
...

I have an Windows installer-based tomcat installation and I don't have an catalina.bat file also. Googling many pages suggest to modify this file (catalina.bat) or register JAVA_OPTS variable, but nothing works. So, where do I have to specify this parameters?:

我有一个基于 Windows 安装程序的 tomcat 安装,但我也没有 catalina.bat 文件。谷歌搜索许多页面建议修改此文件(catalina.bat)或注册 JAVA_OPTS 变量,但没有任何效果。那么,我必须在哪里指定这个参数?:

SET JAVA_OPTS="-Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC”

SET JAVA_OPTS="-Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC”

I have tried to modify the Java Options through Apache Tomcat 7 Properties window but after the modifications the server can't start.

我试图通过 Apache Tomcat 7 属性窗口修改 Java 选项,但修改后服务器无法启动。

tomcat java configuration tab

tomcat java 配置选项卡

My computer has 4Gb RAM installed.

我的电脑安装了 4Gb RAM。

Thanks in advance.

提前致谢。

采纳答案by Manuel Calles

For the following system specifications:

对于以下系统规格:

  • Windows 7 64-bit
  • 4 GB installed RAM
  • Intel Core i7 processor
  • Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
  • 视窗 7 64 位
  • 4 GB 已安装 RAM
  • 英特尔酷睿 i7 处理器
  • Java(TM) SE 运行时环境(构建 1.6.0_25-b06)

The Tomcat 7 Java properties for an acceptable behavior MIGHT be: tomcat java configuration

可接受行为的 Tomcat 7 Java 属性可能是: tomcat java配置

回答by Spindizzy

You should have a small windows application 'tomcat6w.exe' or 'tomcat7w.exe' when tomcat was installed as a windows service. When you start this application it has a tab 'Java' where you can set the JVM parameters. For more details see more memory to Tomcat service.

当 tomcat 作为 Windows 服务安装时,您应该有一个小的 Windows 应用程序“tomcat6w.exe”或“tomcat7w.exe”。当您启动此应用程序时,它有一个选项卡“Java”,您可以在其中设置 JVM 参数。有关更多详细信息,请参阅Tomcat 服务的更多内存

You need to enter only the parameters which start with -X.

您只需要输入以 -X 开头的参数。

回答by teteArg

This work for me in apache-tomcat-8.0.15, but i think it would be the same for all to tomcat's version.

这在apache-tomcat-8.0.15 中对我有用,但我认为对于 tomcat 的所有版本都是一样的。

I had executed regedit and found this path:

我执行了 regedit 并找到了这条路径:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tomcat8

And change ImagePath key to:

并将 ImagePath 键更改为:

C:\apache-tomcat-8.0.15\bin\tomcat8.exe //RS//Tomcat8 ++JvmOptions -XX:PermSize=128m -XX:MaxPermSize=512m