0

I’m using JBoss 7.1.3, JDK 1.6, and Mac 10.9.1. After a number of deploys/undeploys of my WAR file using the Maven Jboss AS plugin, my server dies with the below error …

15:05:10,120 ERROR [org.xnio.listener] (Remoting "daves-macbook-pro:MANAGEMENT" read-1) A channel event listener threw an exception: java.lang.OutOfMemoryError: PermGen space

sudo jmap -dump:format=b,file=/tmp/leak 16274
sudo jhat -J-Xmx2048m /private/tmp/leak

But when I visit the resulting page, http://locohost.mymachine.com:7000/ (except it says "localhost" and not "locohost.mymachine.com"), the output is totally illegible. There are a bunch of lines with references to classes we’ve written, for example

Package org.mainco.subco.myproject.interaction.domain
class org.mainco.subco.myproject.interaction.domain.Note [0x2d145258]
class org.mainco.subco.myproject.interaction.domain.NoteDto [0x2a8de180]
class org.mainco.subco.myproject.interaction.domain.Note_ [0x2baa5980]

But how do I trace that back to parts of our code that are contributing to these PermGen errors?

Dave
  • 15,639
  • 133
  • 442
  • 830
  • "After a number of deploys/undeploys of my WAR file" - this is unlikely to be caused by anything in your code. It's possibly caused by JBoss not cleaning up the undeployed WAR(s) fast enough, or possibly because you have something holding a reference to the WAR (often this is something loaded by the application classloader rather than the war classloader). In either of these cases, JHat and JMap won't help you. – kdgregory Mar 04 '14 at 22:22
  • You can try tracing class loading/unloading to see if there's anything particularly strange. Take a look at [this](http://www.kdgregory.com/index.php?page=java.outOfMemory#permgen) for more info. – kdgregory Mar 04 '14 at 22:26
  • Are you talking about the section that talks about "+TraceClassLoading"? If so, do you mean manually go through the server log and somehow try to figure out what classes were loaded but not unloaded? – Dave Mar 04 '14 at 22:39
  • Yes. Although I prefer using tools like `sed`, `sort`, and `uniq` rather than checking names off a printout. Sorry, but there are no shortcuts to permgen problems. – kdgregory Mar 08 '14 at 12:53

1 Answers1

0

If you want to track down classloader leaks I recommend you to use some more high level tool than jmap and jhat - such as Eclipse Memory Analyzser (MAT). Here is a step by step guide how to do such an analysis. It is part of a blog series that explains different mistakes you may have made in your code, and a list of third party libraries that may trigger the problem.

There is also a Leak prevention library in case you want to get rid of the issue.

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