Maven Jetty OutOfMemoryError plugin when sharing an instance between two web applications

I am using the maven plugin for actuation to run my two web applications. One web application is spring mvc UI and the other is a RESTful web application. I can get two web applications for communication when I run two separate mvn jetty: launch instances and assign different ports. I successfully deploy both instances of the same pier using the same port using the maven pom.xml configuration below. I end up with a space ava.lang.OutOfMemoryError: PermGen. What is the best workaround for this?

<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>7.6.8.v20121106</version> <configuration> <jvmArgs>-Xmx2024m -Xms2024m</jvmArgs> <scanIntervalSeconds>10</scanIntervalSeconds> <webApp> <contextPath>/</contextPath> </webApp> <contextHandlers> <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext"> <war>../../api/target/main-api.war</war> <contextPath>/test</contextPath> </contextHandler> </contextHandlers> </configuration> </plugin> 
+4
source share
6 answers

Add the following jvm argument, if you encounter an error regarding the impossibility of allocating memory, try using a lower value (128 and 256)

 -XX:PermSize=256M -XX:MaxPermSize=512M 

Link

+10
source

Try launching Jetty in bifurcated mode as follows:

 <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>7.6.8.v20121106</version> <executions> <execution> <id>start-jetty</id> <!-- Set this to the appropriate phase: pre-integration-test, or earlier test-compile--> <phase>pre-integration-test</phase> <goals> <goal>run-forked</goal> </goals> </execution> </executions> <configuration> <jvmArgs>-Xmx2048m -Xms1536m -XX:PermSize=128m -XX:MaxPermSize=256m</jvmArgs> <scanIntervalSeconds>10</scanIntervalSeconds> <webApp> <contextPath>/</contextPath> </webApp> <contextHandlers> <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext"> <war>../../api/target/main-api.war</war> <contextPath>/test</contextPath> </contextHandler> </contextHandlers> </configuration> </plugin> 

For more information, see Starting Jetty in a Branched JVM .

And ... Before starting, make sure that you really have 2048 MB of free memory.

+2
source

Try using Plumbr to diagnose any memory leak problems in both web applications. http://plumbr.eu/

+1
source

I end up with java.lang.OutOfMemoryError: PermGen space error

How long? Redistributing Webapps often due to changes?

It is very easy to test classes when redistributing a web application. I would run maven with this setting added to MAVEN_OPTS

-XX: + HeapDumpOnOutOfMemoryError

Run until you get an error from memory, then load the dump from the eclipse mat and see what your perm gen fills. Your web application is likely to leak classes when redeployed .

0
source

It depends on which JVM instance requires more memory. For example, if tests are deployed (by default) and crash due to OutOfMemoryError, try setting up a plugin that runs them:

  <plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>-Xmx1024m</argLine> </configuration> </plugin> 

OR

Beyond the heap memory. You must increase the perm size as well to allow this exception in maven to use these variables in an environment variable. And sometimes it’s also good to extend the size of the memory in memory -

Set the environment variable:

variable name: variable value MAVEN_OPTS: -Xmx512m -XX: MaxPermSize = 256m

Compiled data from a resource

0
source

Please explain: what version of jvm are you using, which operating system are you using, how much physical memory is installed on your computer. What happens if you reduce the memory requirements, for example, to 1400M (this can help when running on 32-bit jvm), that is:

 <jvmArgs>-Xmx1400m -Xms1400m</jvmArgs> 
0
source

Source: https://habr.com/ru/post/1501035/


All Articles