How to increase Tomcat Heap memory on windows

£可爱£侵袭症+ 提交于 2020-01-06 04:37:08

问题


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:

  1. I created the file setenv.bat inside the folder {tomcat}\bin
  2. Inside the file setenv.bat I added the string set "JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx1024m -XX:MaxPermSize=512m -server"

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");        

I get that the Max Heap Size is always 256 MB. Does anybody know what's my error?


回答1:


Please see detail:

  1. I use apache-tomcat-9.0.14-windows-x64.zip
  2. Sure use right java version
  3. Edit catalina.bat add set JAVA_OPTS=-Xms128m -Xmx1024m after setlocal
  4. Start Tomcat with startup.bat
  5. Check JVM with: start jconsole, select Tomcat, select insecure
  6. See XMS, XMX

If you want start Tomcat9w.exe, you need install service




回答2:


Please set in catalina.bat file: Screen shot of catalina.bat file



来源:https://stackoverflow.com/questions/54106789/how-to-increase-tomcat-heap-memory-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!