tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Out of memory exception
Date Thu, 23 Jan 2014 17:03:48 GMT
Randeep wrote:
> Hi all,
> Thanks a lot for valuable points. Here the information you guys asked and
> the changes I made.
> 
> OS : CentOS release 5.4 (Final)
> httpd-2.2.3-65.el5.centos(front_end) +(mod_jk)+ apache-tomcat-6.0.37
> 
> I installed httpd using yum.
> Downloaded tomcat from Apache as compressed archive(tar.gz)
> 
> I'm using following startup script.
> [root@server ~]# cat /etc/init.d/tomcat6
> #!/bin/bash
> # description: Tomcat Start Stop Restart
> # processname: tomcat
> # chkconfig: 234 20 80
> JAVA_HOME=/usr/java/default
> export JAVA_HOME
> PATH=$JAVA_HOME/bin:$PATH
> export PATH
> CATALINA_HOME=/usr/share/apache-tomcat-6.0.37
> case $1 in
> start)
> sh $CATALINA_HOME/bin/startup.sh
> ;;
> stop)
> sh $CATALINA_HOME/bin/shutdown.sh
> ;;
> restart)
> sh $CATALINA_HOME/bin/shutdown.sh
> sh $CATALINA_HOME/bin/startup.sh
> ;;
> esac
> exit 0
> 
> As you said, I removed the JAVA_OPTS declaration from .bash_profile and I
> have created setenv.sh and set JAVA_OPTS in it.
> [root@server bin]# pwd
> /usr/share/apache-tomcat-6.0.37/bin
> 
> [root@server bin]# cat setenv.sh
> export JAVA_OPTS='-Xms256m -Xmx512m -Xss512k -verbose:gc -Xloggc:heap.log'
> 
> Now it shows in grep.
> [root@server bin]# ps aux | grep Bootstrap
> root      1100 33.7  5.4 707052 95240 pts/0    Sl   11:29   0:06
> /usr/java/default/bin/java
> -Djava.util.logging.config.file=/usr/share/apache-tomcat-6.0.37/conf/logging.properties
> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms256m
> -Xmx512m -Xss512k -verbose:gc -Xloggc:heap.log
> -Djava.endorsed.dirs=/usr/share/apache-tomcat-6.0.37/endorsed -classpath
> /usr/share/apache-tomcat-6.0.37/bin/bootstrap.jar
> -Dcatalina.base=/usr/share/apache-tomcat-6.0.37
> -Dcatalina.home=/usr/share/apache-tomcat-6.0.37
> -Djava.io.tmpdir=/usr/share/apache-tomcat-6.0.37/temp
> org.apache.catalina.startup.Bootstrap start
> root      1158  0.0  0.0   3932   692 pts/0    R+   11:29   0:00 grep
> Bootstrap
> [root@server bin]#
> 
> But nothing came in heap.log. So I better monitor this and if I get the OOM
> again I have to increase Max limit!

Maybe you should provide a full path for the -Xloggc option ?

> 
> 
> On Thu, Jan 23, 2014 at 8:50 PM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> Randeep,
>>
>> On 1/23/14, 7:43 AM, Randeep wrote:
>>> I'm getting out of memory exception errors.
>> :(
>>
>>> Exception in thread "Timer-1" java.lang.OutOfMemoryError: Java heap
>>> space at java.util.Arrays.copyOf(Arrays.java:2882) at
>>>
>> java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
>>>
>> at
>>> java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572)
>>>
>>>
>> at java.lang.StringBuffer.append(StringBuffer.java:320)
>>> at org.json.JSONArray.toString(JSONArray.java:834) at
>>> org.json.JSONObject.valueToString(JSONObject.java:1359) at
>>> org.json.JSONObject.toString(JSONObject.java:1233) at
>>> com.xxx.xxx.servlet.WServlet.writeProgramJson(WServlet.java:503) at
>>> com.xxx.xxx.servlet.WServlet$1.run(WServlet.java:414) at
>>> java.util.TimerThread.mainLoop(Timer.java:512) at
>>> java.util.TimerThread.run(Timer.java:462)
>> If you are trying to serialize huge JSON objects, this is going to
>> happen. I'm not sure if JSON is as smart as the Java Serialization
>> engine, but if you have a circular-reference in your object graph, I'd
>> be willing to bet that the JSON serializer will run forever and
>> exhaust your heap.
>>
>> It's also possible that you simply have a tiny heap and need more,
>> especially if you aren't currently setting any heap parameters.
>>
>>> Is there anyway to see currently set jvm heap size details? Any
>>> linux commands.
>> You can attach any profiler to your app. Good luck catching this in
>> the act, though, in production.
>>
>> You can also use "jmap -heap" which comes with the JDK. Just point it
>> at a process and you'll get a heap summary from a running JVM. Make
>> sure your JVM and jmap version match.
>>
>>> I have tried creating setenv.sh and putting the new parameters in
>>> it. but echo $JAVA_OPTS was not giving any value.
>> setenv.sh is run during Tomcat startup. Running "echo $JAVA_OPTS" from
>> the command-line isn't going to reveal anything. What you want to do
>> is modify setenv.sh, re-launch Tomcat, and then look at the process
>> command line... something like this:
>>
>> $ ps aux | grep Bootstrap
>>
>> This should give you the whole command-line for Tomcat, and you can
>> verify that your heap options have been set.
>>
>>> So I have put in .bash_profile and run it. Then restarted tomcat6.
>> Don't do that: it will only work if you login using bash, and it won't
>> work for other users you may have to restart Tomcat.
>>
>>> this is the line I added in .bash_profile. JAVA_OPTS="-Xms256m
>>> -Xmx512m -Xss512k -verbose:gc -Xloggc:heap.log"
>> You'll need to "export" JAVA_OPTS, otherwise it won't do anything for you.
>>
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1
>> Comment: GPGTools - http://gpgtools.org
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>
>> iQIcBAEBCAAGBQJS4TM+AAoJEBzwKT+lPKRYfB4QAMP4/MORiK92nK4kJ+KD9alc
>> 2QYcriasb8QkPPgvYHGhGaxeLIprb1TE6tZdMSp08bHadDr+HpSbxi5xq9C6A1RJ
>> fabHj9ShrXqdtTFiewPH3P/ulvaaJNPD1LeIFBwoG7/4vAIGKW48gLhaRUYcbe+z
>> lV2NsZ18u38EZ9KRR8An66jX4PkwMXxl4QdQx5HDmuS/Sx8G7AfDVkuSB5PMNXbg
>> TVlSEz5VeJnEGtBwnjgIa6ZSTv+iIv+nsw4WVuMe+4h1R07e1axxNismkgpUsU46
>> Ra4P7TssgdrqXFXmX4+kPNzd3xbbhPYIOOrQ0PYt6wGF0Wd9N1r/gvvViDbgghca
>> wp39c3VJM8eE2vy9n0XCGYBkdq2DnRNVFV2y2xnfwecWKtDPEWfklTk8ZvbcAyxe
>> hi3hxQnChCk74nxd/hvI1uNfgHcd/NwtmifwXPNM0BQCZ+AJarCbGca+a/BTTBaX
>> txVIuIEf3jt/gpFu28UI8kt7Hx/PgWJ32QFyIPCbH5EYaSiKSz/Q6wCTvJTbUG4s
>> GCK8AB/rGf1Z8efKlUZw2ESr1yX/VBCu9uOEK/60v+AAthiubq+O2ke1TzWKvy/I
>> MxDhNiMo710w98h5hqIl5SthwXCgv3vEaaiUgDUV8zP3CoOtHL61NNZmLrMBTD2X
>> 18aTMDKJ9BTvoYoZcmyV
>> =IL2E
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message