Tuesday, September 15, 2009

Getting PermGen information

The permanent generation is the area of heap that holds all the reflective data of the virtual machine
itself, such as class and method objects.
Configuring the size of the permanent generation can be important for applications that dynamically
generate and load a very large number of classes. If an application loads “too many” classes then it is possible it will abort with an OutOfMemoryError.
The specific error will look like :
“Exception in thread XXXX java.lang.OutOfMemoryError: PermGen space”

In 1 terminal start an application.
I am just using the jfc Notepad application here, since it is pretty passive and doesn't interfere with the screen while I am trying to write this.

bash-3.00$ ./java -jar ../demo/jfc/Notepad/Notepad.jar

Get the pid in this case 2239
bash-3.00$ ./jps
3131 Jps
2239 Notepad.jar
10792 Main

Now in another terminal try running this

bash-3.00$ ./jmap -permstat 2239
Attaching to process ID 2239, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 14.0-b10
finding class loader instances ..Finding object size using Printezis bits and skipping over...
Finding object size using Printezis bits and skipping over...
Finding object size using Printezis bits and skipping over...
computing per loader stat ..done.
please wait.. computing liveness.....done.

class_loader classes bytes parent_loader alive? type

1596 7131080 null live
0xe6e91088 1 1152 null dead sun/reflect/DelegatingClassLoader@0xb7847 8d0
0xe65142c8 6 17968 0xe6424958 dead sun/reflect/misc/MethodUtil@0xb7d67248
0xe6426528 0 0 0xe6424958 live java/util/ResourceBundle$RBClassLoader@0x b796ec78
0xe6e8a128 1 1152 null dead sun/reflect/DelegatingClassLoader@0xb7847 8d0
0xe656d8a0 1 1184 0xe65142c8 dead sun/reflect/DelegatingClassLoader@0xb7847 8d0
0xe693cd20 1 1792 null dead sun/reflect/DelegatingClassLoader@0xb7847 8d0
0xe641e710 1 8080 null live sun/misc/Launcher$ExtClassLoader@0xb79214 78
0xe6e8ee40 1 1152 null dead sun/reflect/DelegatingClassLoader@0xb7847 8d0
0xe6555668 1 1752 null dead sun/reflect/DelegatingClassLoader@0xb7847 8d0
0xe6e8cd78 1 1768 null dead sun/reflect/DelegatingClassLoader@0xb7847 8d0
0xe6424958 87 810144 0xe641e710 live sun/misc/Launcher$AppClassLoader@0xb7964f d0

total = 12 1697 7977224 N/A alive=4, dead=8 N/A

Typically, we get the output in this form.
For each class loader object, the following details are printed:
1. The address of the class loader object – at the snapshot when the utility was run.
2. The number of classes loaded (defined by this loader with the method(java.lang.ClassLoader.defineClass).
3. The approximate number of bytes consumed by meta-data for all classes loaded by this class loader.
4. The address of the parent class loader (if any).
5. A “live” or “dead” indication – indicates whether the loader object will be garbage collected in the future.
6. The class name of this class loader.

No comments:

Post a Comment