How to Increase Apache Tomcat Heap Memory Size
Apache Tomcat commonly used to run web apps, commonly made by Java or Spring Boot. It's trusted and well known for it's realibility and easy to maintain. But ever wonder somehow you got Out of Memory Error from your web app? And how to deal with it?
Disclaimer: Not all Out of Memory means that you need to increase your heap size. Please make sure that you didn't use too much explicit objects that could have memory leaks, or check wether your un-optimized code causes this.
Increasing Heap Memory from your Java installation might not help much. Each instance have it's own limiter on using Heap Sizes. So does Apache Tomcat. But is it a bad news?
No, it's not a bad news at all. In fact, Apache Tomcat has a GUI to help you set the memory used by Apache Tomcat easily. To do this, please follow this step:
- Go to your Apache Tomcat install directory then go to the BIN folder (if you're using Tomcat 9, the path sould be C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin)
- Open tomcat[v]w.exe where v here is a version number. For example: tomcat9w.exe
- Go to the Java tab
- There you could set Initial memory pool and Maximum memory pool as you like, and leave Thread stack size empty.
- For Best Practice, set Initial and Maximum memory pool the same value (example: both 2048)
- Back to General Tab
- Click Start if the server hasn't started yet.
- If you already start the Tomcat Server, click restart. If restart button is disabled, click stop and when it's stopped, click start.
- Go to localhost:8080/manager/status to see the increased memory (change the port according to your setup)
Comments
Post a Comment
Feel free to ask in comment, but I won't guarantee that I will answer it quickly as this blog is just my notepad and I opened it whenever I need to.