0

I'm getting an OutOfMemory: PermGen space error when running my application. A brief description:

The error does not occur when running from the source code, but it does occur when I run from the deployed .jnlp launcher. The error occurs in a screen that retrieves data from our company database via RMI. Running from the source code and from the launcher both use the same RMI url. Running from the source code and from the launcher both use the same Java version (6_38). The app is hosted in OC4J 10.1.3. When the error occurs, it kills not only my app, but also the Java console.

I've added the below options to the server properties in the Application Sever Control, as suggested in some other questions, but to no avail.

-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled

The error as recorded in the java console is as such, taken from the trace file:

Couldn't process record:
java.lang.OutOfMemoryError: PermGen space
    at sun.misc.Unsafe.defineClass(Native Method)
    at sun.reflect.ClassDefiner.defineClass(Unknown Source)
    at sun.reflect.MethodAccessorGenerator$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.reflect.MethodAccessorGenerator.generate(Unknown Source)
    at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor(Unknown Source)
    at sun.reflect.ReflectionFactory.newConstructorForSerialization(Unknown Source)
    at java.io.ObjectStreamClass.getSerializableConstructor(Unknown Source)
    at java.io.ObjectStreamClass.access$1500(Unknown Source)
    at java.io.ObjectStreamClass$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.io.ObjectStreamClass.<init>(Unknown Source)
    at java.io.ObjectStreamClass.lookup(Unknown Source)

I'm not sure what other info might be helpful, and I'm at a loss as to how to continue. Any guidance would be welcome.

Travis
  • 1,044
  • 1
  • 17
  • 36

2 Answers2

1

If you have ClassLoader/PermGen leaks in a web application you can get rid of them using the ClassLoader Leak Prevention library.

In case you want to track down leaks yourself this blog series will be of help.

Mattias Jiderhamn
  • 2,053
  • 1
  • 13
  • 6
0

try first to increase your perm size as the default value is usually too low (for 64bit jvms mainly).

the arguments needed are -XX:PermSize and -XX:MaxPermSize

a max value of 256M is usually enought.

Farid
  • 2,265
  • 18
  • 14
  • It is already 256M, unfortunately. From what I've read, it sounds like I've got a memory leak somewhere, but the error messages aren't helpful in that regard (at least to me). The application is an inherited one, and none of the original writers are employed at my workplace anymore. – Travis Nov 01 '13 at 19:28
  • I did go ahead and try upping it to 512M, just to see. It didn't stop the error from occurring, but it did cause the application to freeze and die more smoothly, so that's something. – Travis Nov 01 '13 at 19:55
  • if it is really a memory leak you could use the following 2 arguments : `- XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=path_to_file` which will dump the content of the memory when the exception occurs (set the path to file). you can then use applications like [http://www.eclipse.org/mat/](http://www.eclipse.org/mat/) to open the file created and see what was the issue. But be aware it's not an easy task. – Farid Nov 02 '13 at 07:17
  • Thanks for that, @Farid. Looks like I have a fun time ahead of me. I'll go ahead and mark this as the answer, as from what I've read it **is** the answer for most situations like this. – Travis Nov 05 '13 at 15:01