Redeploying a Grails App using Jenkins on Tomcat fills PermGen Space - java

Currently we are having various problems with the deployment of our Grails application on Tomcat 6, mainly it's about memory usage issues and redeployment via Jenkins.
The Application eats more and more memory, and we tried to resolve this with CMSPermGenSweepingEnabled (we are using UseConcMarkSweepGC), so now the temporary classes used by Groovy should get cleaned up.
What still is a problem is that on each Redeploy (with jenkins) the app needs around 150 mb of additional Permgen space ... any idea how to avoid this?
We are using Grail 1.3.7, and our current configuration flags are
-Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties
-Djava.awt.headless=true
-Xms2048M
-Xmx2048M
-XX:MaxPermSize=1024m
-XX:PermSize=1024m
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseConcMarkSweepGC
-Djava.net.preferIPv4Stack=true
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6
-Dcatalina.home=/usr/share/tomcat6
-Djava.io.tmpdir=/tmp/tomcat6-tmp

It's very popular tomcat issue, they even have some recommendations: http://wiki.apache.org/tomcat/OutOfMemory, but at most cases it's works only for small or fully controlled project (mean 'project without any external library'). All solid projects I ever seen fails under tomcat with this error :(
My recomendation - restart Tomcat instance after deploy.

We've experienced similar issues with our Grails applications on Tomcat. Our solution is the same as what Igor suggests, restart Tomcat after a deploy.
We have two production servers setup in a cluster so they share sessions. We take one server down, undeploy the application, restart tomcat, deploy the new version of the application, and bring that server back up. Then repeat the process on the other server. So far this is working for us.

Related

Constant dspace error java.lang.OutOfMemoryError: Java heap space

I have a DSpace server, after uprading from version 4.3 to 5.1, it constantly stops working after some hours with following error:
java.lang.OutOfMemoryError: Java heap space
I've read answers to the same questions, but they didn't help me.
My JAVA_OPTS: -Xmx4096M -Xms4096M -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8
Here are my logs:
dspace.log.2015-04-21: http://jpst.it/ylU4
tomcat7-stderr.2015-04-20.log: http://jpst.it/ylTN
localhost_access_log.2015-04-20.txt: http://jpst.it/ylTT
I searched the internet for a solution and could not find one, does any one have a clue?
Your tomcat log file quite clearly says that it isn't using the JAVA_OPTS you're passing in:
INFO: Command line argument: -Xmx256m
In my experience, DSpace 5 needs at least 512MB; your 4GB look a little excessive unless your DSpace instance is very big / gets lots of traffic.
You aren't telling us what operating system you're using, so it's hard to give advice on how where to set these properly. Start with your tomcat startup script and/or the tomcat configuration files. On my Red Hat Enterprise Linux 6.6 boxes (with tomcat6), the correct place for the memory settings is /etc/tomcat6/tomcat6.conf.

Incredibly slow Java application launching on Tomcat Server in Eclipse (Spring Tool Suite)?

please, take a look at this snapshot:
And it happens over and over when I run a new Java web application on a Tomcat Server (right click on the project -> Run -> Run on Server). Eclipse/STS (I am using STS 3.6.4 with Eclipse Luna 4.4, as you can see from the screenshot) hangs almost for an infinite time, and consumes all the CPU.
I have the following settings inside STS.ini:
-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m
Does anyone ever experienced a similar problem? If so, what did you do? Anyway, what can I do in order to find the root cause of the issue and resolve?
I didn't experienced this problem before (I guess it started when I upgraded from STS 3.6.3 to STS 3.6.4, but I can't say that this is the cause).
Thanks for the attention!

IntelliJ IDEA 13.1 - how to prevent low memory problems on a 32-bit OS (Win 7) with 3GB RAM

I have some memory issues while using the IntelliJ IDEA 13.1 (currently 13.1.6), due to insufficient amount of RAM. I work on a quite big project and often run some maven builds as well as a web application in debug mode. I've got a 32-bit OS (Windows 7), 3 GB RAM and an SSD. I use the JDK 7.
The Maven builds which are run inside of IntelliJ IDEA fail often due to insufficient memory and I have to resume them from the point of failure.
An alert "Your computer is low on memory" is shown by the Windows system often when I perform the Maven builds or try to start the web application using IntelliJ IDEA.
I use the following settings in the configuration file "idea.exe.vmoptions" (located in the same directory as the "idea.exe" file):
-server
-Xms128m
-Xmx700m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=64m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
The MAVEN_OPTS environment variable is set to the following value:
-Xmx1024m -Dfile.encoding=UTF8
I already disabled unused plugins and found out that it's useful to restart the IDEA after memory-consuming operations, like e.g. after a Maven build. I also found out that closing as much other applications as possible helps a bit, but not always.
However, all aforementioned tricks didn't eliminate the problems.
What are your recommendations, apart from extending the RAM or changing to a 64-bit OS?
Do you know some better settings for the "idea.exe.vmoptions" file?

VisualVM 1.3.7 cannot get the list of Java Web Applications from GlassFish

When I run a Java application (simple application with a main method) the VisualVM list it as running application. However, after running my Java Web application on NetBeans, VisualVM 1.3.7 just shows NetBeans IDE 7.2.1 (pid 4708), VisualVM and GlassFish (pid 2136) under Local.
In Netbeans configuration, I am using JDK 1.7, the J2EE Version is Java EE6, Profile is set to Web and it is running on GlassFish Server 4.
Also I set the web container to high, based on "Cannot Get The List Of Web Applications From GlassFish" section of this.
Based on my research to solve the problem I downloaded and installed VisualVM-Extensions plugin as well to no avail.
I used all following methods to run VisualVM.
1) I ran it by executing the VisualVM.exe file
2) using following command in console
visualvm --jdkhome "C:\Program Files\Java\jdk1.7.0_13" --userdir "C:\Users\Alex\AppData"
3) using following command in console
visualvm --jdkhome "C:\Program Files\Java\jdk1.7.0_13" --userdir "C:\Documents and Settings\Alex\AppData\Roaming\VisualVM\1.3.7"
OK, so VisualVM is simply going to look at the JVMs running. When you have a Web application running within Glassfish, there is a JVM that contains Glassfish (inside of which your web application is hosted). VisualVM is only able to see what is running at the JVM layer. It's not going to look at the JVM hosting glassfish any differently than it would if you directly ran a Java class using the command-line approach.
Unless there is a VisualVM plugin for Glassfish out there that knows how to query the relevant JMX beans to extract the Container details defined within, stock-standard VisualVM will just look at the container as any other JVM.
If you want to see what Web Applications (or anything else, for that matter) are deployed within your Glassfish container, you could use it's web console, or its JMX interface if you want to programmatically inspect it.

PermGen space error while application is running

My Web application is running on tomcat apache-tomcat-6.0.35 and It was working fine witout any issue.But today I show bellow exception in catalina.out log and was unable to login to the system.
Jul 9, 2013 2:40:15 PM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: PermGen space
I was under impression this exception can be ocuured when you deploy or redeploy a application. But I got this when the application is running without any issues. What could be the reason for this. Kindly advice
Each webapp in Tomcat has a separate class loader with a separate set of loaded classes. When we start Tomcat it does not load all classes of all its apps at once but rather it loads the apps lazily. When an app becomes active it starts loading its classes and it may happen that JVM runs out permgen space. That is, it may happen even without redeploying apps.
add these Optionsto JVM command line when Tomcat is started Or add to IDE VM Options
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
OR
-XX:MaxPermGen=128M
It sounds like one of your webapps is consuming a lot of memory. Have you tried raising the PermGen size? In $CATALINA_HOME/bin/catalina.sh you can add
-XX:PermSize=512m -XX:MaxPermSize=512m
to your JAVA_OPTS so that it allocates enough space to run.
You are getting out of permGen space, try to change this parameters on your tomcat start script
/etc/init.d/tomcat6
JAVA_OPTS="-Djava.awt.headless=true -XX:MaxPermSize=512M"
Set the memory amount as you need.
It definitely is an error that often shows up during deployments. I've seen it occur any number of times in both Grails and Java applications. You can increase your permgen space by adjusting the JVM startup param -XX:MaxPermSize, ie:
-XX:MaxPermSize=256m
This thread covers the issue in detail: Thread
I had this error a few days ago. I fixed it by restarting the real machine - there was a problem with a deploy.
Also you can fix it by adding
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8
-server -Xms1536m -Xmx1536m
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"
See possible fix

Categories

Resources