How do I discover what is in the permanent generation

Tom picture Tom · Oct 11, 2008 · Viewed 8.6k times · Source

Given a heapdump or a running VM, how do I discover what the contents of the permanent generation is ? I know about 'jmap -permstat' but that's not available on Windows.

Answer

laszlot picture laszlot · Oct 11, 2008

The permanent generation contains the class object. So you should check the heap dump or other form of object list for classes. If you have problem with the size of permanent generation usually it is caused by two reason:

  • your program or a library you use creates classes dynamically and the default size of permanent generation is too small - simple increate the size with -XX:MaxPermSize=256m
  • your program or a library you use creates new classes dynamically every time it is called, so the size of permanent generation increases non-stop - this is a programming error you should fix it (or search a fix/create a bug report)

To see which is your case check the size of the permanent generation over a larger period.

And a good overview about permanent generation:

http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation