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.
PermGen (Permanent Generation) is a special heap space separated from the main memory heap. The JVM keeps track of loaded class metadata in the PermGen. Additionally, the JVM stores all the static content in this memory section.
The PermGen area of the Java heap is used to store metadata such as class declarations, methods and object arrays. Therefore, the PermGen size requirements depend on the number of classes and methods as well as their size. Java memory is separated into different regions - Young, Tenured and PermGen.
permanent-generation is not part of heap Save this answer.
-XX:PermSize : It's is initial value of Permanent Space which is allocated at startup of JVM. Examples of using -XX:PermSize VM (JVM) option in java > Example1 of using -XX:PermSize VM (JVM) option in java > java -XX:PermSize=512 MyJavaProgram. It will set initial value of Permanent Space as 512 bytes to JVM.
This article Memory Monitoring with Java SE 5 describes how to programmatically discover information on heap usage, memory pools (including permgen space) and so on. Its very simple:
MemoryUsage usage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
long nonHeapFree = usage.getMax() - usage.getUsed();
long nonHeapTotal = usage.getMax();
In my testing on OSX (Sun VM) "non heap memory usage" matches the values returned for the permgen pool closely and presumably will do something useful on VMs that don't have permgen.
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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With