The Source for Java Technology Collaboration
User: Password:



Rich Unger

Rich Unger's Blog

debugging PermGen OutOfMemoryError problems in windows

Posted by richunger on September 29, 2006 at 04:45 PM | Comments (2)

Recently, a bug showed up in my stack: "java.lang.OutOfMemoryError: PermGen space"

I loathe these kinds of bugs.  They're notoriously difficult to reproduce, and tough to isolate.

Coincidentally, around that time Gregg Sporar posted about this very type of memory leak: http://weblogs.java.net/blog/gsporar/archive/2006/09/javazone_sessio.html

He suggests using jmap to see what's in PermGen space.  Unfortunately, I'm on windows.  Until jdk6, jmap wasn't even available on windows, and even in jdk6, the windows version doesn't support the -permspace flag.

Then, my coworker Raj pointed me to jconsole.  This is a tool that comes with jdk5 and lets you monitor the JVM's MBeans graphically.  All you need to do is launch your VM with the -Dcom.sun.management.jmxremote flag.

In my case, I was profiling NetBeans' internal tomcat server, so I entered this flag in Windows...Runtime...Servers...Bundled Tomcat...Properties...Platform...VM Options and restarted the server.

Two screens were of use to me in jconsole.  The first is the memory usage screen:

jconsole-mem.png

And the second is the classes screen, which shows me how many classes have been loaded, and has a handy checkbox that will enable printing to stdout the names of all classes as they're being loaded.

jconsole-classes.png

In the end, I found that the problem was in NetBeans itself: http://www.netbeans.org/issues/show_bug.cgi?id=85179

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Hint: Use jconsole.exe out of JDK 1.6 - same functionality, but imo much improved GUI interactions.
    You can of course attach to 1.5 VMs.

    Posted by: ricon on October 03, 2006 at 01:23 AM

  • We've got a PermGen in a complex EJB 2.1 / 3.0 app and I'm using jconsole to hunt it down, noticing that a lot of sun.reflect.GeneratedMethodAccessor get loaded and never discarded. The problem: Even a 5 line app that only calls Thread.sleep() in a loop produces lots of sun.reflect.GeneratedMethodAccessor (with the difference that they are garbage collected when I force it). So it would be great to know what sun.reflect.GeneratedMethodAccessor are and in which cases they get loaded. And whether the use of jconsole has an impact on this (like a Heisenberg-Effect).

    Posted by: uberdose on April 16, 2007 at 01:40 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds