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:
- 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"
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?
Please see detail:
If you want start Tomcat9w.exe, you need install service
Please set in catalina.bat file: Screen shot of catalina.bat file