Skip to main content

debugging PermGen OutOfMemoryError problems in windows

Posted by richunger on September 29, 2006 at 4:45 PM PDT

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:

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


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.


In the end, I found that the problem was in NetBeans itself: