views:

169

answers:

1

I've implemented a filter (javax.servlet.Filter). I now have some strange behavior when enabling JMX. As soon as I enable it I will get a "java.lang.OutOfMemoryError: PermGen space" error within short time.

I really can't understand why this is. When leaving JMX disabled the application seem to be running fine.

+3  A: 

You'll need to start your application with a command line option like

-XX:MaxPermSize=100m

(using 100 megabytes in this example).

PermGen space is a part of the memory, where things like string constants, class files etc. reside, i.e. everything that is created once, and can't be garbage collected. Not every JVM uses this concept, but the Sun JVM does.

Chris Lercher
AFAIK, permgen *is* garbage collected in recent JVMs, but only in a full garbage collection. And the chances are that not much space can be reclaimed ... because of the nature of the objects that are placed there.
Stephen C
@Stephen: Absolutely, thanks. The exact handling of PermGen space is implementation dependent. My description is very sketchy indeed. Essentially, I meant: It's created once per class, and removing an instance won't be enough to make the PermGen space available to be garbage collected. Thanks for your comment, it's good to be more precise (though JVM implementors would probably still laugh at my attempt to describe it :-)
Chris Lercher
Thanks a lot! :)
l3dx