Les commandes
- jps : affiche les processus Java en cours d'execution avec le pid
- jinfo : affiche les informations d'une JVM (proprietes, conf, ...)
- jstat : affiche les statisitiques (en autre GC) de la JVM en cours d'execution
- jmap : /!\ freeze JVM pour faire les dumps, outils de faire un heap dump de la memoire JVM
- jhat : outil pour la lecture et le requetage d'un fichier heap dump
- jstack : thread dump
Exemple avec la commande jstat
$ jstat -gc 27061
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
51200,0 51200,0 21704,1 0,0 409600,0 385620,3 108800,0 89146,5 59520,0 59435,0 234 15,624 8 5,044 20,668
jstat -gcause 27061 (en pourcentage)
$ jstat -gcutil 27061
S0 S1 E O P YGC YGCT FGC FGCT GCT
42,39 0,00 94,59 81,94 99,86 234 15,624 8 5,044 20,668
$ jstat -class 27061
Loaded Bytes Unloaded Bytes Time
7904 16567,7 40 67,8 7,87Exemple avec la commande jmap
$ jmap -histo 27061
$ jmap -heap 27061
99.50254387212259% used
num #instances #bytes class name
----------------------------------------------
1: 217116 105868488 [I
2: 1290034 67781296 [B
3: 282344 49407976 [C
4: 2240 13849864 [D
5: 86614 11901864
6: 183839 11765696 java.util.LinkedHashMap$Entry
7: 86614 10406304
8: 80563 10016456 [Ljava.util.HashMap$Entry;
9: 243601 9744040 java.lang.String
10: 7864 8770264 $ jmap -heap 27061
Attaching to process ID 27061, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 14.2-b01
using thread-local object allocation.
Mark Sweep Compact GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 1572864000 (1500.0MB)
NewSize = 524288000 (500.0MB)
MaxNewSize = 524288000 (500.0MB)
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 21757952 (20.75MB)
MaxPermSize = 536870912 (512.0MB)
Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 471859200 (450.0MB)
used = 241119808 (229.94976806640625MB)
free = 230739392 (220.05023193359375MB)
51.099948459201386% used
Eden Space:
capacity = 419430400 (400.0MB)
used = 241119808 (229.94976806640625MB)
free = 178310592 (170.05023193359375MB)
57.48744201660156% used
From Space:
capacity = 52428800 (50.0MB)
used = 0 (0.0MB)
free = 52428800 (50.0MB)
0.0% used
To Space:
capacity = 52428800 (50.0MB)
used = 0 (0.0MB)
free = 52428800 (50.0MB)
0.0% used
tenured generation:
capacity = 160825344 (153.375MB)
used = 96493080 (92.0229721069336MB)
free = 64332264 (61.352027893066406MB)
59.9986778203316% used
Perm Generation:
capacity = 61210624 (58.375MB)
used = 60906128 (58.08460998535156MB)
free = 304496 (0.2903900146484375MB)
99.50254387212259% used
Thread dump JVM
$ kill -3
ou
$ jstack
Lire de multiples thread dump avec samourai : http://samuraism.jp/samurai/en/index.html
$ jmap -dump:format=b,file=c:tempheap.bin
Lancer un full GC
$ jmap -histo:live $PID
ou
$ jstack
Lire de multiples thread dump avec samourai : http://samuraism.jp/samurai/en/index.html
Head dump JVM
/!\ Freeze JVM$ jmap -dump:format=b,file=c:tempheap.bin
Lancer un full GC
$ jmap -histo:live $PID