如何在Windows上增加Tomcat堆内存 [英] How to increase Tomcat Heap memory on windows
问题描述
我在互联网上和这里的stackoverflow上都读了很多文章,但是我仍然无法增加 Tomcat Heap Siz e. 可能我犯了一个我无法识别的错误.
I read many posts on the internet and here on stackoverflow, but I'm still not able to increase Tomcat Heap Size. Probably I made an error that I can't recognize.
遵循此指南我做了这些步骤:
Following this guide I did these steps:
- 我在文件夹 {tomcat} \ bin 中创建了文件 setenv.bat
- 在文件 setenv.bat 中,我添加了字符串 set"JAVA_OPTS =%JAVA_OPTS%-Xms128m -Xmx1024m -XX:MaxPermSize = 512m -server" >
- I created the file setenv.bat inside the folder {tomcat}\bin
- Inside the file setenv.bat I added the string set "JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx1024m -XX:MaxPermSize=512m -server"
当我运行Tomcat,然后启动我的应用程序(例如localhost:8080/appName)时,我尝试通过这种方式了解堆信息:
When I run Tomcat and then I launch my app (for instance localhost:8080/appName) and I try to know the heap informations this way:
long maxHeapSize = Runtime.getRuntime().maxMemory();
long freeHeapSize = Runtime.getRuntime().freeMemory();
long totalHeapSize = Runtime.getRuntime().totalMemory();
System.out.println("Max Heap Size = " + (maxHeapSize/1024/1024)+ " MB");
System.out.println("Free Heap Size = " + (freeHeapSize/1024/1024)+ " MB");
System.out.println("Total Heap Size = " + (totalHeapSize/1024/1024)+ " MB");
我知道最大堆大小始终为256 MB. 有人知道我的错误吗?
I get that the Max Heap Size is always 256 MB. Does anybody know what's my error?
推荐答案
请查看详细信息:
- 我使用 apache-tomcat-9.0.14-windows-x64.zip
- 请确保正确使用 Java版本
- 在setlocal之后编辑catalina.bat添加设置JAVA_OPTS = -Xms128m -Xmx1024m
- 使用 startup.bat 启动Tomcat.
- 使用以下方法检查JVM:启动 jconsole ,选择不安全
- 请参见 XMS,XMX
- I use apache-tomcat-9.0.14-windows-x64.zip
- Sure use right java version
- Edit catalina.bat add set JAVA_OPTS=-Xms128m -Xmx1024m after setlocal
- Start Tomcat with startup.bat
- Check JVM with: start jconsole, select Tomcat, select insecure
- See XMS, XMX
如果要启动Tomcat9w.exe,则需要安装服务
If you want start Tomcat9w.exe, you need install service
这篇关于如何在Windows上增加Tomcat堆内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!