One of our client’s CLASSIC ACCESSORIES java application in a single server. If we try to load all these applications simultaneously, some will not load and some will be slow. When we check tomcat’s log file catalina.out, it says, java.lang.OutOfMemoryError: Java heap space. The cause of this is explained below,
Normally java applications are allowed to use only limited memory and java memory is separated into two different regions. These regions are called Heap space and Permgen (for Permanent Generation). The size of those regions is set during the Java Virtual Machine (JVM) launch and can be customized by specifying JVM parameters -Xmx and -XX:MaxPermSize. The java.lang.OutOfMemoryError: Java heap space error occurs when it attempts to add more data into the heap space area, but there is not enough room for it.
The solution to fix this problem is to increase the heap space(Default value may be 128 MB). We can customize the heap space by specifying the JVM parameters -Xmx and -XX:MaxPermSize.
In order to achieve this, please do the following,
- Edit（or Create a new file, if it not exist) file setenv loacted in the bin directory of tomcat(/usr/share/tomcat7/bin).
- We can increase the maximum Java heap size to 512 MB, by inserting the following lines:
Hope this helps! Please feel free to get in touch with us for further queries.
Good to know about this.