5. Exercises
Compile a bunch of .java files and output to
“classes” directory
Create jar file
Write “main” class, manifest-file
Create jar file
Create another two jar files, and try “Class-
Path”
8. JVM Heap
Young Generation Eden Space C
A
B
from to
Old Generation Tenured Space
Permanent
Generation
class
A
class
B
class
C Permanent Space class
D
class
E
class
F
9. JVM Heap
GC1
B
Young Generation Eden Space C
to from
Old Generation Tenured Space
Permanent
Generation
class
A
class
B
class
C Permanent Space class
D
class
E
class
F
10. JVM Heap
GC1 GC2
Young Generation Eden Space
from to
Old Generation Tenured Space B
Permanent
Generation
class
A
class
B
class
C Permanent Space class
D
class
E
class
F
16. jps
List all JVM instances
Compared with “ps -elf | grep java”
jstack
Print thread stack dump of a JVM instance
Similar as “pstack” and “gstack”
jstat
JVM statistics monitoring
http://docs.oracle.com/javase/1.5.0/docs/
tooldocs/share/jstat.html
17. jmap
Dump all JVM objects
jmap -dump:live,format=b,file=<filename>
jhat
Analyze dump file generated by “jmap”
Start an http server where to connect to show analysis result
mat
Memory Analyzer
Dump file analysis tool based on Eclipse
More efficient and be able to analyze really large dump file
jvisualvm
Originated in NetBeans
All-in-one tuning and troubleshooting tool
24. Homework
Apply all the tools to AddressBook project
You may skip compilation and packaging
tools
You must execute your compiled binary
from CLI using “java”
Tuning and troubleshooting tools are
mandatory