Pasupathi Rajamanickam
Pasupathi Rajamanickam

Reputation: 2052

java.lang.OutOfMemoryError: PermGen space in embeded jetty

I am trying to deploy multiple application in a jetty server. Currently I have 50 applications and I'm following the answer from this jetty server 9.1 multiple embeded ports and application in same server instance.

I'm getting java.lang.OutOfMemoryError: PermGen space at the 38th deployment. How do I solve this?

Upvotes: 1

Views: 7576

Answers (3)

Philipp Sander
Philipp Sander

Reputation: 10249

Increase the perm and heap size of your jetty instance

http://pic.dhe.ibm.com/infocenter/chghelp/v5m3/topic/com.ibm.rational.change.install.doc/topics/ch_t_ig_change_java_max_heap_jty.html

when you run it via commandline:

java -jar -XX:MaxPermSize=512m jety.jar 

if this doesn't work, increase the size (e.g. 1024m)

Upvotes: 1

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49462

Any memory control options are part of the JVM that you start for your embedded Jetty application. That means, in order for you to increase the PermGen that the JVM uses, you'll need to use the command line option -XX:MaxPermSize against the JVM when you start your embedded Jetty instance.

Example:

$ java -XX:MaxPermSize=1024m -cp myserver.jar com.company.EmbeddedMe

Since you added the tag, I'll assume you want to know how to configure your "Run Configuration" for this same thing.

In Run > Run Configurations > Arguments Tab > VM Arguments, put -XX:MaxPermSize=1024m

Upvotes: 11

Hendrik
Hendrik

Reputation: 5310

Deploying generates a bunch of Class objects which are allocated in the permanent space and never really garbage collected.

To solve this, you might want to increase the size of the permanent space with the JVM option -XX:MaxPermSize=128m (see here for more JVM options/descriptions).

Note that starting with Java8, perm space has been removed. So as an alternative you could also upgrade your JDK to Java8.

Upvotes: 0

Related Questions