2015-01-16 18 views
6

Attualmente sto ottenendo un java.lang.OutOfMemoryError: PermGen space. Sto usando Jetty e Linux Ubuntu. Ho provato a leggere e a provare le diverse soluzioni fornite in precedenti domande simili, ma non ho alcun successo. Una domanda simile è statojava.lang.OutOfMemoryError: Errore spazio permGen con Jetty

Dealing with “java.lang.OutOfMemoryError: PermGen space” error

Ma queste soluzioni sembrano essere utilizzando Tomcat al posto di Jetty. Continuo a ricevere l'errore di memeory se devo ridistribuire il mio servizio alcune volte. Ad esempio per testare questo sto andando alla mia cartella webapps e in esecuzione touch * .xml per aggiornare il timestamp quindi eseguire nuovamente il jetty e ottengo l'errore di memoria insufficiente. Nella mia cartella pontile (quella che comprende bin, doc, etc, lib, i registri, moduli, start.jar) Sto facendo funzionare

java -jar ../start.jar 

Ma questo mi dà l'errore. Allora ho provato quello che ho letto negli altri esempi come:

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

o

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled 

o

-XX:MaxPermSize=128m 

Poi quando vado a Firefox e passare alla localhost:8080 e rinfresco, in il terminale continuo a ricevere l'errore

java.lang.OutOfMemoryError: PermGen space 

risposta

2

Speriamo che sarete in grado di sbarazzarsi di questi problemi, semplicemente usando il mio ClassLoader Leak Prevention library. Ci sono molti errori diversi che possono causare questo tipo di perdite di memoria, sia nel proprio codice che nelle librerie di terze parti. Maggiori informazioni sul problema, su come rintracciarlo e sui trasgressori conosciuti, possono essere trovati in this blog series of mine. Nota specifica this bug nel Jetty stesso che potrebbe causare questo tipo di perdite per alcune versioni.

0

È possibile aggiungere tali parametri nel file start.ini nella cartella principale del Jetty. Se non funziona, prova a impostare un valore MaxPermSize più alto, ad esempio 1024 m.

4

Non c'è niente che puoi fare se non alzando il MaxPermSize a un valore più alto (ad es 1024m.):

-XX:MaxPermSize=1024m 

Questo è un problema comune, e si spiega anche in Jetty Documentation - Prevent Memory Leaks sezione:

Permgen problems

The JSP engine in Jetty is Jasper. This was originally developed under the Apache Tomcat project, but over time has been forked by many different projects. All jetty versions up to 6 used 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's Glassfish project, which is now the reference implementation.

All forks of Jasper suffer from a problem whereby the permgen space can be put under pressure by using jsp tag files. This is because of the classloading architecture of the jsp implementation. Each jsp file is effectively compiled and its class loaded in its own classloader so as to allow for hot replacement. Each jsp that contains references to a tag file will compile the tag if necessary and then load it using its own classloader. If you have many jsps that refer to the same tag file, then the tag's class will be loaded over and over again into permgen space, once for each jsp. The relevant Glassfish bug report is bug # 3963 , and the equivalent Apache Tomcat bug report is bug # 43878 . The Apache Tomcat project has already closed this bug report with status WON'T FIX, however the Glassfish folks still have the bug report open and have scheduled it to be fixed. When the fix becomes available, the Jetty project will pick it up and incorporate into our release program.

0

In Jetty 9.2+

Nella directory ${jetty.base}, aggiungere la configurazione del modulo JVM + predefinita

[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]$ 

Passare modificare il ${jetty.base}/start.ini e configurare le proprietà, togliere quelle cose che si desidera (non si forgiano di decommentare --exec) pontile da utilizzare quando si avvia se stesso.

Esempio:

# --------------------------------------- 
# 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

Si tratta di una questione più grande, ma questo ha risolto il mio problema:

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