Changing setenv.sh in tomcat6 didn't increase Heap size - java

In my Confluence plugin development, my local confluence instance uses tomcat6. (Confluence Version 5.6.5 , OS : Mac OS X)
I need to increase the heap size from the default 512m to 1024m.
I added a new setenv.sh file inside the bin directory of the location below.
../target/container/tomcat6x/apache-tomcat-6.0.20/bin
And also added the below contents to the file
export CATALINA_OPTS="$CATALINA_OPTS -server -Xms1024m -Xmx1024m -XX:MaxPermSize=512m"
but when i restarted the confluence instance I didnt find the change of heap size being reflected.
Following are the JVM statistics generated during the atlas-run command after the changes are made.
could some one clarify me if I am doing something wrong ??
thanks in advance!

Related

Increase Heap Size for Java server (Increasing JVM Memory of Go Server)

I am trying to increase JVM Memory of my Go server.
This is what I see on /etc/default/go-server
# Ansible managed
export GO_SERVER_SYSTEM_PROPERTIES="-Dmail.smtp.starttls.enable=true"
export GO_SERVER_PORT=8153
export GO_SERVER_SSL_PORT=8154
export JAVA_HOME=/usr/lib/jvm/java
export SERVER_WORK_DIR=/var/lib/go-server
export GO_SERVER_SYSTEM_PROPERTIES="$GO_SERVER_SYSTEM_PROPERTIES -Dgo.plugin.build.status.go-server=http://localhost:8153"
Any idea how I can add -Xmx2048m here for GO_SERVERSYSPROPS?
Thanks.
JAVA_OPTS is the standard environment variable that some servers and other java apps append to the call that executes the java command.
JAVA_OPTS='-Xmx2048m'

Apache Tomcat Server OutOfMemoryError [duplicate]

I have this VM with tomcat, java, and grails in it. I've been getting permgen errors so I looked around and found the solution:
set JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
I use SSH to access the vm and type the arguments above. I suppose that would fix the problem. Thing is, I wanted to make sure that I did it correctly. So I searched again on how I could check the current permSize and this is the solution I got:
jinfo -flag MaxPermSize 6444
6444 is the pid, and as a response, I got this.
-XX:MaxPermSize=85983232
Question: Is the value of the maxPermSize in bytes? because, if it is, then that would mean that the java_opts command didn't work. I am expecting to get 512m but 85983232 bytes = 82 mb.. Or am I seeing it wrong..? Can anybody enlighten me on this? D:
You have to change the values in the CATALINA_OPTS option defined in the Tomcat Catalina start file. To increase the PermGen memory change the value of the MaxPermSize variable, otherwise change the value of the Xmx variable.
Linux & Mac OS: Open or create setenv.sh file placed in the "bin" directory. You have to apply the changes to this line:
export CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
Windows:
Open or create the setenv.bat file placed in the "bin" directory:
set CATALINA_OPTS=-server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m
Don't put the environment configuration in catalina.bat/catalina.sh. Instead you should create a new file in CATALINA_BASE\bin\setenv.bat to keep your customizations separate of tomcat installation.
So you are doing the right thing concerning "-XX:MaxPermSize=512m": it is indeed the correct syntax. You could try to set these options directly to the Catalyna server files so they are used on server start.
Maybe this post will help you!
How to make sure that Tomcat6 reads CATALINA_OPTS on Windows?
Completely removed from java 8 +
Partially removed from java 7 (interned Strings for example)
source

WAR file is giving me out of memory error

I am using tomcat 6 and the WAR file I have deployed is giving me out of memory error. I have installed tomcat6 using windows installer because of it I am unable to find any catalina.bat in tomcat6.0\bin folder where I can configure CATALINA_OPTS variable.
If you are not able to find the catalina.bat then edit your tomcat6w.exe and add
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseConcMarkSweepGC
-XX:PermSize=128m
-XX:MaxPermSize=512m
You should change the “Xms” and “PermSize” value base on your server
capability.
Once done with editing simply Restart Tomcat.
Hope it helps!
If you have trouble setting CATALINA_OPTS in tomcat installation, you can set it as a environment variable in windows.
UPDATE:
If the previous method is not working then you can create a file, setenv.bat in bin directory of tomcat.
And in that file you can put the arguments like:
set CATALINA_OPTS= "JVM Conditions here"
This did the trick for me, try it out.
Few links for your reference:
http://www.oracle-base.com/articles/misc/apache-tomcat-7-installation-on-windows.php
How to tune Tomcat 5.5 JVM Memory settings without using the configuration program

Java Heap Space Error in tomcat

I am using Tomcat 7.0.28. I have deployed a war file.
In this war file there is a server like structure where we can upload the files.
Now when i access that web page it is working, but when i try to upload the large files it is showing error of JAVA Heap Space.
How can i solve it?
You are probably trying to put the whole file in memory. Your first shot should be to change the -Xmx parameter at the Tomcat JVM startup options to give it more memor. Aside from that, you'll have to read the file one chunk at a time, and write it on the hard drive, so as to free the memory.
You can increase HeapSize in tomcat using below command .
Linux : Open Catalina.sh file placed in the "bin" directory. You have to apply the changes to this line
CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m "
Windows:
Open the "Catalina.bat" file placed in the "bin" directory
set CATALINA_OPTS=-server -Xms256m -Xmx1024m
Restart the tomcat after above change.

Tomcat 7: How to set initial heap size correctly?

I was trying to adjust initial heap size of a tomcat 7 (CentOS, java -version: 1.6.0_25-b06) instance by adding the following line to catalina.sh:
export CATALINA_OPTS="-Xms=512M -Xmx=1024M"
Starting up tomcat fails and logs the following message to catalina.out:
Invalid initial heap size: -Xms=512m
Could not create the Java virtual machine.
What is wrong with these options?
You must not use =. Simply use this:
export CATALINA_OPTS="-Xms512M -Xmx1024M"
Use following command to increase java heap size for tomcat7 (linux distributions) correctly:
echo 'export CATALINA_OPTS="-Xms512M -Xmx1024M"' > /usr/share/tomcat7/bin/setenv.sh
You might no need to having export, just add this line in catalina.sh :
CATALINA_OPTS="-Xms512M -Xmx1024M"
setenv.sh is better, because you can easily port such configuration from one machine to another, or from one Tomcat version to another. catalina.sh changes from one version of Tomcat to another. But you can keep your setenv.sh unchanged with any version of Tomcat.
Another advantage is, that it is easier to track the history of your changes if you add it to your backup or versioning system. If you look how you setenv.sh changes along the history, you will see only your own changes. Whereas if you use catalina.sh, you will always see not only your changes, but also changes that came with each newer version of the Tomcat.
Go to "Tomcat Directory"/bin directory
if Linux then create setenv.sh else if Windows then create setenv.bat
content of setenv.* file :
export CATALINA_OPTS="$CATALINA_OPTS -Xms512m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx8192m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"
after this restart tomcat with new params.
explanation and full information is here
http://crunchify.com/how-to-change-jvm-heap-setting-xms-xmx-of-tomcat/
After spending good time time on this . I found this is the what the setenv.bat must look like . No " characters are accepted in batch file.
set CATALINA_OPTS=-Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=768m
echo hello "%CATALINA_OPTS%"
Take care with change in Debian distributions! I tried to change CATALINA_OPTS in my Debian 7 and the results where that tomcat didn't start anymore. Thus I solved this issue by changing the property JAVA_OPTS in place of CATALINA_OPTS, like this
export JAVA_OPTS="-Xms512M -Xmx1024M"
Just came across this and I've implemented Nathan's solution:
add the line (changing the values as required):
export JAVA_OPTS="-Xms512M -Xmx1024M"
to /usr/share/tomcat7/bin/setenv.sh
If that file doesn't exists then create it and
chown root:root it
chmod 755 it
And then restart tomcat and
check it with
ps aux | grep logging
Which should just pick up the instance and show the java parms
It works even without using 'export' keyword. This is what i have in my setenv.sh (/usr/share/tomcat7/bin/setenv.sh) and it works.
OS : 14.04.1-Ubuntu
Server version: Apache Tomcat/7.0.52 (Ubuntu)
Server built: Jun 30 2016 01:59:37
Server number: 7.0.52.0
JAVA_OPTS="-Dorg.apache.catalina.security.SecurityListener.UMASK=`umask` -server -Xms6G -Xmx6G -Xmn1400m -XX:HeapDumpPath=/Some/logs/ -XX:+HeapDumpOnOutOfMemoryError -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:SurvivorRatio=8 -XX:+UseCompressedOops -Dcom.sun.management.jmxremote.port=8181 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Dserver.name=$HOSTNAME"
If it's not work in your centos 7 machine "export CATALINA_OPTS="-Xms512M -Xmx1024M"" then you can change heap memory from vi /etc/systemd/system/tomcat.service file then this value shown in your tomcat by help of ps -ef|grep tomcat.

Categories

Resources