Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to view objects in permgen

Tags:

java

permgen

I have some problems with permgen overflow. What tools I can use to view what classes are now loaded into permgen and how much memory they use? Thanks.

like image 262
alex543 Avatar asked Sep 24 '10 12:09

alex543


1 Answers

Maybe you have a large code base or are interning lots of strings.

Try jmap:

jmap -permstat <pid>

(Note: the permstat option is not available in Windows)

Example:

$ jmap -permstat 22982
Attaching to process ID 22982, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.0-b16
100691 intern Strings occupying 5641096 bytes.
finding class loader instances ..Finding object size using Printezis bits and skipping over...
done.
computing per loader stat ..done.
please wait.. computing liveness..done.
class_loader    classes bytes   parent_loader   alive?  type

<bootstrap>     303     1355992   null          live    <internal>
0xdd159fe8      9       94104   0xdd153c30      live    sun/misc/Launcher$AppClassLoader@0xae7fcfa0
0xdd153c30      0       0         null          live    sun/misc/Launcher$ExtClassLoader@0xae7b0178

total = 3       312     1450096     N/A         alive=3, dead=0     N/A

You can also try dumping the heap to a file and then loading it into Eclipse Memory Analyser, which will give you useful information such as a Leak Suspects Report and Dominator Tree.

jmap -dump:format=b,file=heap.bin 22982

If necessary, you can increase your PermGen space by using the -XX:MaxPermSize JVM option.

like image 160
dogbane Avatar answered Sep 19 '22 14:09

dogbane