-----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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org