Java.lang.OutOfMemoryError: PermGen space error with Jetty

I am currently getting java.lang.OutOfMemoryError: PermGen space . I am using Jetty and Linux Ubuntu. I tried to read and try the various solutions that were provided in previous similar questions, but I did not succeed. One such question was

Working with java.lang.OutOfMemoryError: PermGen space error

But these solutions seem to use Tomcat instead of Jetty. I continue to extract an error from memory if I reinstall my service several times. For example, to check this, I go to my webapps folder and run touch * .xml to update the timestamp and then restart jetty and I get an error from memory. In my folder with the pier (the one that contains bin, doc, etc., Lib, logs, modules, start.jar) I run

 java -jar ../start.jar 

But that gives me an error. Then I tried what I read in other examples, such as:

 java -jar ../start.jar JAVA_OPTS="-Xms256m -Xmx512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled" 

or

 -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled 

or

 -XX:MaxPermSize=128m 

Then when I go to firefox and go to localhost:8080 and update, in the terminal I keep getting an error

 java.lang.OutOfMemoryError: PermGen space 
+6
source share
5 answers

I hope you can get rid of these problems just by using the ClassLoader leak prevention library . There are many different errors that can cause such memory leaks, both in your own code and in third-party libraries. More information about the problem, its tracking and known criminals can be found in this series of my blogs . In particular, pay attention to this error in Jetty itself, which can cause these leaks for some versions.

+2
source

You can do nothing but raise MaxPermSize to a higher value (for example, 1024 m):

 -XX:MaxPermSize=1024m 

This is a common problem and is also explained in the Jetty documentation section - preventing memory leaks :

Permit Issues

Jetty's JSP engine - Jasper. It was originally developed in the Apache Tomcat project, but over time many different projects were forked. All prefixes up to 6 use Apache-based Jasper exclusively, with Jetty 6 using Apache Jasper only for JSP2.0. With the advent of JSP 2.1, Jetty 6 switched to using Jasper from Sun Glassfish , which is now the reference implementation.

All Jasper's forks suffer from a problem in which the permgene space can be pressurized using jsp tag files. This is due to the loading architecture in the jsp implementation. Each jsp file is compiled efficiently and its class is loaded into its own class loader, therefore, to provide a hot swap. Each jsp containing links to the tag file will compile the tag, if necessary, and then load it using its own class loader. If you have a lot of jsps that reference the same file tag, then the tag class will be loaded again and again into the perimeter space, once for each jsp. The corresponding Glassfish error report is error # 3963 , and the equivalent Apache Tomcat error report is error # 43878 . The Apache Tomcat project has already closed this bug report with the status NOT CORRECTED, however, Glassfish people still have a bug report is open and has planned to fix it. When a fix becomes available, the Jetty project will pick it up and include it in our release .

+4
source

You can add these parameters to the start.ini file in the Jetty home folder. If justt doesn't work, you can try setting a higher MaxPermSize, something like 1024 m.

0
source

In Jetty 9.2 +

In your ${jetty.base} add the jvm module + default configuration

 [user]$ cd mybase [mybase]$ java -jar /path/to/jetty-distribution/start.jar --add-to-start=jvm INFO: jvm initialised in ${jetty.base}/start.ini (appended) [mybase]$ 

Now go to your ${jetty.base}/start.ini and configure the properties, uncomment the things you want (do not fake --exec to split) the berth to use at startup.

Example:

 # --------------------------------------- # Module: jvm --module=jvm ## JVM Configuration ## If JVM args are include in an ini file then --exec is needed ## to start a new JVM from start.jar with the extra args. ## ## If you wish to avoid an extra JVM running, place JVM args ## on the normal command line and do not use --exec --exec -Xmx1024m -Xmn512m -XX:MaxPermSize=128m # -XX:+UseConcMarkSweepGC # -XX:ParallelCMSThreads=2 # -XX:+CMSClassUnloadingEnabled # -XX:+UseCMSCompactAtFullCollection # -XX:CMSInitiatingOccupancyFraction=80 # -verbose:gc # -XX:+PrintGCDateStamps # -XX:+PrintGCTimeStamps # -XX:+PrintGCDetails # -XX:+PrintTenuringDistribution # -XX:+PrintCommandLineFlags # -XX:+DisableExplicitGC # -Dorg.apache.jasper.compiler.disablejsr199=true 
0
source

This is an old question, but it solved my problem:

contextHandler.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");

0
source

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


All Articles