Q:

java.lang.OutOfMemoryError: PermGen space in play framework

Edit:- play ~run to run my project
how to remove this problem,
my project is in testing phase. daily after 5-6 hour it stops suddenly and giving the below error.
what to do to remove this error?
i am developing this project in scala 2.1 with playframework 2.2
    java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
Caused by: java.lang.OutOfMemoryError: PermGen space
    at sun.misc.Unsafe.defineClass(Native Method)
    at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
    at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
    at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
    at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:113)
    at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:331)
    at java.io.ObjectStreamClass.getSerializableConstructor(ObjectStreamClass.java:1376)
    at java.io.ObjectStreamClass.access$1500(ObjectStreamClass.java:72)
    at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:493)
    at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:468)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:468)
    at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:365)
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:602)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1622)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1706)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1344)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
[error] Total time: 11065 s, completed 8 Feb, 2014 6:12:52 PM
1. Waiting for source changes... (press enter to interrupt)

java.lang.OutOfMemoryError: PermGen space
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 4 s, completed 8 Feb, 2014 6:12:57 PM
2. Waiting for source changes... (press enter to interrupt)

java.lang.OutOfMemoryError: PermGen space
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 4 s, completed 8 Feb, 2014 6:13:08 PM
3. Waiting for source changes... (press enter to interrupt)

java.lang.OutOfMemoryError: PermGen space
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 6 s, completed 8 Feb, 2014 6:13:54 PM
4. Waiting for source changes... (press enter to interrupt)
[error] Expected letter
[error] Expected symbol
[error] Expected '!'
[error] Expected '+'
[error] Expected '++'
[error] Expected ';'
[error] Expected end of input.
[error] Expected 'show'
[error] Expected '*'
[error] Expected '{'
[error] Expected project ID
[error] Expected configuration
[error] Expected key
[error] 9000
[error] ^
sbt appears to be exiting abnormally.
  The log file for this session is at /tmp/sbt7580663022166474466.log
java.lang.OutOfMemoryError: PermGen space
Error during sbt execution: java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-125" java.lang.OutOfMemoryError: PermGen space

A:

I had the same problem so I exported the SBT_OPTS as followed :
export SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:PermSize=512M -XX:MaxPermSize=1024M"

A:

In general it means you didn't give enough memory to your JVM or you have a memory leak. See how people address such problems here: Dealing with "java.lang.OutOfMemoryError: PermGen space" error or search for non-play specific error: "java.lang.OutOfMemoryError: PermGen".
Looking at your log I noticed that you are probably running it from SBT or some other build tool like Maven ("Waiting for source changes..."). To help SBT prevent memory leaks you can add these arguments when you lunch it:
java -Xms128M -Xmx1200M -Xss20M -XX:MaxPermSize=1200m -XX:+CMSClassUnloadingEnabled -jar `dirname $0`/sbt-launch.jar "$@"

Note the class unloading command line arg. In general I noticed that apps running in SBT still manage to leak resources no matter what you do, but in production it does not happen. You could try to run in a forked JVM mode to help SBT - see SBT-Revolver plugin for example. If you want to really know how your application consumes memory and whether it has memory leaks run it outside of a build tool, i.e. deploy it to container like Tomcat or run a jar or what have you. You can attach tools like jconsole to observe memory usage.

