Page tree
Skip to end of metadata
Go to start of metadata

The Java Application Server Throws "Out of Memory" Errors

Even though you may have a large amount of RAM available, the Java Virtual Machine doesn't get to see all of that - by default it is limited to only 256Mb.

For example, if you are using Tomcat, you can view how much memory is being consumed by apps. To do this you need to have the management console enabled.

On a vanilla install this is done by editing the file /tomcat/install/directory/conf/tomcat-users.xml adding these lines in:

<role rolename="manager-gui" />
<user username="tomcat" password="password" roles="manager-gui"/>

Then, restart the server and go to a browser and open the default tomcat page http://localhost:8080. On the top right hand side are three buttons, the first of which should be "Server Status". Click that link, login with the details you set above and you should be able to see the memory consumption (see the figure below for an example).


To increase the amount of memory:

Tomcat :

Edit the setenv.sh (Unix) or setenv.bat (Windows) to read as follows:

 

windows config

On Windows, please prefix each line with 'set' and remove the quotes . So the configuration would look like:

 

set CATALINA_OPTS= -Dconfig.file=/config/file/location/application.conf 
set JAVA_OPTS= -Xms2048m -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -Dfile.encoding=utf-8 -Djava.awt.headless-true -XX:+UseParallelGC -XX:MaxGCPauseMillis=100

  

CATALINA_OPTS=" -Dconfig.file=/config/file/location/application.conf 
JAVA_OPTS=" -Xms2048m -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -Dfile.encoding=utf-8 -Djava.awt.headless-true -XX:+UseParallelGC -XX:MaxGCPauseMillis=100"

Jetty :

Edit the start.ini file to read as follows:

#=========================================================== 
# Jetty start.jar arguments 
# Each line of this file is prepended to the command line 
# arguments # of a call to: 
# java -jar start.jar [arg...] 
#=========================================================== 
-Xms2048m -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=512m -Dconfig.file=/config/file/location/application.conf

 

Restart the service and confirm the settings have been applied like so:

  • No labels