SlideShare a Scribd company logo
1 of 92
Download to read offline
Ferramentas da
   Hotspot
2
Agenda

     • jps                             • jstack
     • jinfo                           • jhat
     • jmap                            • jdb
     • jstat                           • hprof

http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/tooldescr.html   3
jps
Lista processos Java




                       4
5
$ jps -h
illegal argument: -h
usage: jps [-help]
       jps [-q] [-mlvV] [<hostid>]

Definitions:
    <hostid>:     <hostname>[:<port>]



                                        6
$   ps | grep -i java
 4008 p2 S+     0:00.02 /bin/sh /Users/alegomes/JavaTools/jopr-server-2.2.0/jbossas/bin/
run.sh -P /
 4017 p2 S+    33:21.61 /Library/Java/Home/bin/java -Dprogram.name=run.sh -Dapp.name=rhq-
server -Xm
11989 p4 R+     0:00.00 grep -i java
  840 p5 S+     7:10.01 /Library/Java/Home/bin/java -Dprogram.name=run.sh -Xms128m -Xmx512m
-Dsun.r




                                                                                            7
$   ps | grep -i java
 4008 p2 S+     0:00.02 /bin/sh /Users/alegomes/JavaTools/jopr-server-2.2.0/jbossas/bin/
run.sh -P /
 4017 p2 S+    33:21.61 /Library/Java/Home/bin/java -Dprogram.name=run.sh -Dapp.name=rhq-
server -Xm
11989 p4 R+     0:00.00 grep -i java
  840 p5 S+     7:10.01 /Library/Java/Home/bin/java -Dprogram.name=run.sh -Xms128m -Xmx512m
-Dsun.r




                                                                                            7
$   jps
2989
2614 Jps
3614


$   jps -v
2617 Jps -Dapplication.home=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/
Home -Xms8m

2989 -Xbootclasspath/a:/System/Library/PrivateFrameworks/
JavaApplicationLauncher.framework/Resources/LauncherSupport.jar -
Dapple.laf.useScreenMenuBar=true -Dapple.awt.showGrowBox=true -
Dapple.awt.antialiasing=false -Dcom.apple.mrj.application.apple.menu.about.name=FreeMind
-Dcom.apple.mrj.application.live-resize=true -Dcom.apple.smallTabs=false -
Dapple.awt.textantialiasing=false

3614 -Xbootclasspath/p:/Applications/Firefox 3.0.1.app/Contents/MacOS/plugins/
MRJPlugin.plugin/Contents/MacOS/MRJPlugin.jar -Dnetscape.oji.plugin.home=/Applications/
Firefox 3.0.1.app/Contents/MacOS/plugins/MRJPlugin.plugin/Contents/MacOS -Xmx96m -
Djavaplugin.maxHeapSize=96m -Xbootclasspath/a:/System/Library/Frameworks/
JavaVM.framework/Versions/1.5/Home/lib/deploy.jar:/System/Library/Frameworks/
JavaVM.framework/Versions/1.5/Home/lib/plugin.jar:/System/Library/Frameworks/
JavaVM.framework/Versions/1.5/Home/lib/ext/apple_provider.jar -Xbootclasspath/p:/
Applications/Firefox 3.0.1.app/Contents/MacOS/plugins/JavaEmbeddingPlugin.bundle/
Contents/Resources/Java/JavaEmbeddingPlugin.jar -Djep.pluginhome=/Applications/Firefox
3.0.1.app/Contents/MacOS/plugins/JavaEmbeddingPlugin.bundle -Djep.version=0.9.6.4 -
Djep.version.applet=true -Djep.debug.visibility.applet=true -
Djep.debug.release.applet=true -Djep.debug.updates.applet=true -DtrustProxy=true vfprintf
                                                                                          8
jinfo
informações de configuração




                             9
10
$ jinfo
Usage: jinfo [option] <pid>
                (to connect to a live java process)
   or jinfo [option] <executable> <core>
                (to connect to a core file)
   or jinfo [option] [server_id@]<remote server IP or hostname>
                (to connect to a remote debug server)

where option must be one   of:
    -flags      to print   VM flags
    -sysprops   to print   Java System properties
    <no option> to print   both of the above
    -h | -help to print    this help message




                                                                  11
$ jinfo 2650
Attaching to process ID 2650, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_16-132
Java System Properties:

java.vendor = Apple Computer, Inc.
sun.java.launcher = SUN_STANDARD
sun.management.compiler = HotSpot Client Compiler
os.name = Mac OS X
sun.boot.class.path = /Users/alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed/activation.jar:/Users/
alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed/jaxb-api.jar:/Users/alegomes/jbtun/app/
jboss-5.0.0.GA/bin/../lib/endorsed/resolver.jar:/Users/alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/
endorsed/serializer.jar:/Users/alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed/stax-api.jar:/Users/
alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed/xalan.jar:/Users/alegomes/jbtun/app/jboss-5.0.0.GA/
bin/../lib/endorsed/xercesImpl.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/
classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/ui.jar:/System/Library/
Frameworks/JavaVM.framework/Versions/1.5.0/Classes/laf.jar:/System/Library/Frameworks/JavaVM.framework/
Versions/1.5.0/Classes/sunrsasign.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/
jsse.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/jce.jar:/System/Library/
Frameworks/JavaVM.framework/Versions/1.5.0/Classes/charsets.jar
java.vm.specification.vendor = Sun Microsystems Inc.
java.runtime.version = 1.5.0_16-b06-275
org.apache.catalina.core.StandardHost.autoDeploy = false
user.name = alegomes
jboss.remoting.version = 22
jboss.bind.address = 127.0.0.1
jboss.messaging.connector.bisocket.port = 4457
awt.nativeDoubleBuffering = true
tomcat.util.buf.StringCache.byte.enabled = true
jboss.home.dir = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA
com.arjuna.common.util.logging.DebugLevel = 0x00000000
java.naming.factory.initial = org.jnp.interfaces.NamingContextFactory
user.language = en
sun.boot.library.path = /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries
com.arjuna.ats.jta.lastResourceOptimisationInterface = org.jboss.tm.LastResource
jboss.home.url = file:/Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/
java.version = 1.5.0_16omes$                                                                            12
(...)
java.rmi.server.codebase = http://127.0.0.1:8083/
java.io.tmpdir = /tmp
java.vendor.url.bug = http://developer.apple.com/java/
jboss.server.data.dir = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/server/
default/data
java.rmi.server.hostname = 127.0.0.1
jboss.vfs.forceCopy = true
os.arch = ppc
java.awt.graphicsenv = apple.awt.CGraphicsEnvironment
org.apache.catalina.core.StandardHost.deployXML = false
java.ext.dirs = /Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/
Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext
PROPERTIES_FILE = tsmx.properties
mrj.version = 1040.1.5.0_16-275
user.dir = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/bin
org.apache.catalina.core.StandardHost.deployOnStartup = false
apple.awt.graphics.UseQuartz = true
line.separator =

java.vm.name = Java HotSpot(TM) Client VM
jboss.server.base.dir = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/server
org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger
com.arjuna.common.util.logging.FacilityLevel = 0xffffffff
jboss.server.base.url = file:/Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/
server/
javax.management.builder.initial = org.jboss.mx.server.MBeanServerBuilderImpl
file.encoding = MacRoman
org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP = true
catalina.ext.dirs = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/server/default/
lib
java.specification.version = 1.5
jboss.server.name = default

VM Flags:
-Dprogram.name=run.sh -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -
Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -
Djava.endorsed.dirs=/Users/alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed                 13
Garbage Collector




                    14
Regra Geral do GC




15




     http://chaoticjava.com/posts/how-does-garbage-collection-work/
Problema


As memórias estão cada vez maiores.




                                      16
Constatação


Alta mortalidade infantil de objetos




                                       17
Idéia!
         18
GC Geracional



Old             Young




                        19
GC Geracional



Old             Young




           alta mortalidade
            GC frequente
            espaço menor


                              19
GC Geracional



         Old                Young




 baixa mortalidade     alta mortalidade
GC não tão frequente    GC frequente
   espaço maior         espaço menor


                                          19
GC Geracional



Perm     Old           Young




                               20
GC Geracional



Perm     Old           Young


                       Pouco espaço
                       Coleta rápida
                       Muitas coletas




                                        20
GC Geracional



Perm      Old             Young


         Muito espaço     Pouco espaço
        Coleta demorada   Coleta rápida
         Poucas coletas   Muitas coletas




                                           20
GC Geracional



 Perm               Old             Young


   Dados           Muito espaço     Pouco espaço
permanentes.      Coleta demorada   Coleta rápida
                   Poucas coletas   Muitas coletas
Coletados uma
 vez na vida e
outra na morte


                                                     20
Compactação
 processo de alto custo




                          21
Compactação
            defragmentação


mem frag




 cópia




deleção




 cópia

                             22
Compactação
            defragmentação


mem frag




 cópia




deleção




 cópia

                             23
Compactação
            defragmentação


mem frag




 cópia




deleção




 cópia

                             24
Compactação
            defragmentação


mem frag




 cópia




deleção




 cópia

                             25
Copy
menos custoso que a compactação




                                  26
Copy
        defragmentação


                         S0

                         S1




                         S0
cópia
                         S1
                              27
Copy

            Na Young Generation,
          faz-se a cópia de objetos
          ao invés da compactação.

  Este mecanismo é eficiente pois atinge-se a
defragmentação da memória sem a necessidade
                de varrê-la.


                                               28
Perm   Old   S0   S1   Eden




                              29
Perm   Old    S0      S1        Eden



                  Áreas
             temporárias para
             cópia de objetos




                                       29
http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html   30
31
Minor
Collection
             31
32




     http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html
Promoção




33




     http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html
Mark Sweep



34




     http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html
Resumo



         35
jmap
estatísticas de memória




                          36
37
$ jmap
Usage: jmap [option] <pid>
                (to connect to a live java process)
   or jmap [option] <executable> <core>
                (to connect to a core file)
   or jmap [option] [server_id@]<remote server IP or hostname>
                (to connect to a remote debug server)

where option must be one of:
    <no option> same as -heap
    -heap       to print java heap summary
    -heap:format=b|x    to dump java heap in hprof binary format
    -histo      to print histogram of java object heap
    -permstat   to print permanent generation statistics
    -h | -help to print this help message




                                                                   38
$ jmap -heap 2650
Attaching to process ID 2650, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_16-132

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
   MinHeapFreeRatio   =   40
   MaxHeapFreeRatio   =   70
   MaxHeapSize        =   536870912 (512.0MB)
   NewSize            =   655360 (0.625MB)
   MaxNewSize         =   4294836224 (4095.875MB)
   OldSize            =   1441792 (1.375MB)
   NewRatio           =   8
   SurvivorRatio      =   8
   PermSize           =   8388608 (8.0MB)
   MaxPermSize        =   268435456 (256.0MB)



                                                    39
(...)
Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 22413312 (21.375MB)
   used      = 19454264 (18.55303192138672MB)
   free      = 2959048 (2.8219680786132812MB)
   86.79781015853436% used
Eden Space:
   capacity = 19922944 (19.0MB)
   used      = 19174288 (18.286026000976562MB)
   free      = 748656 (0.7139739990234375MB)
   96.24224211040296% used
From Space:
   capacity = 2490368 (2.375MB)
   used      = 279976 (0.26700592041015625MB)
   free      = 2210392 (2.1079940795898438MB)
   11.242354543585526% used
To Space:
   capacity = 2490368 (2.375MB)
   used      = 0 (0.0MB)
   free      = 2490368 (2.375MB)
   0.0% used
tenured generation:
   capacity = 194772992 (185.75MB)
   used      = 120429336 (114.8503646850586MB)
   free      = 74343656 (70.8996353149414MB)
   61.83061355857798% used
Perm Generation:
   capacity = 45613056 (43.5MB)
   used      = 45396720 (43.29368591308594MB)
   free      = 216336 (0.2063140869140625MB)
   99.5257147427263% used                        40
$ jmap -histo       2650
Object Histogram:

Size
 Count
 Class description
-------------------------------------------------------
26114008
 232479
 char[]
15697136
 21720
 byte[]
13056704
 103094
 * ConstMethodKlass
9788712
       407863
 java.lang.String
8013376
       250418
 java.util.TreeMap$Entry
6704152
       147510
 * SymbolKlass
5777192
       103094
 * MethodKlass
5671208
       62558
 java.util.HashMap$Entry[]
5589144
       232881
 java.util.HashMap$Entry
5561696
       9877
 * ConstantPoolKlass
4230480
       9877
 * InstanceKlassKlass
3768000
       47100
 java.lang.reflect.Method
3234112
       44591
 java.lang.Object[]
3134336
       8290
 * ConstantPoolCacheKlass
3089048
       15456
 int[]
2513760
       31422
 java.util.zip.ZipEntry
2375560
       59389
 java.util.HashMap
2267480
       56687
 java.util.TreeMap
2210048
       69064
 java.util.concurrent.ConcurrentHashMap$Segment
1673216
       26144
 org.jboss.mx.server.InvocationContext
1658616
       69109
 java.util.concurrent.locks.ReentrantLock$NonfairSync
1517520
       31615
 org.jboss.virtual.plugins.context.zip.ZipEntryHandler
1496760
       69219
 java.util.concurrent.ConcurrentHashMap$HashEntry[]
1442960
       90185
 org.jboss.logging.Logger
1442960
       90185
 org.jboss.logging.log4j.Log4jLoggerPlugin               41
$ jmap -permstat 2650
Attaching to process ID 2650, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_16-132
finding class loader instances ..Unknown oop at 0x065ee230
Oop's klass is null
Finding object size using Printezis bits and skipping over...
done.
computing per loader stat ..done.
please wait.. computing
liveness....................................................................................Unknown oop
at 0xf23b7c68
Oop's klass is 0x075bd890
Liveness analysis: WARNING: UnknownOopException for oop at 0xf23b7c68
LivenessAnalysis: WARNING: sun.jvm.hotspot.utilities.AssertionFailure: should not reach here during
traversal
Liveness analysis: WARNING: AddressException at 0x87859397 while traversing oop at 0x87859393
done.
class_loader    classes bytes   parent_loader   alive? type

<bootstrap>     2740    5755040    null             live   <internal>
0x0db29710      3       4616       null             live   org/jboss/classloader/spi/base/
BaseClassLoader@0x26ddb718
0x102d5e68      1       1392     0x0b1572a8         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x0a706728      1       1392     0x09e804e0         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x0d7f8858      1       1392     0x0b1572a8         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x0dc9c290      5       21608      null             live   org/jboss/classloader/spi/base/
BaseClassLoader@0x26ddb718
0x0f0380a0      1       1392     0x09e804e0         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x0f4e31f0      1       1392     0x0dc9bf70         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x0df37b30      1       1392     0x09e804e0         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x09f38480      1       840        null             dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x0e74a6a0      1       1392     0x0b1572a8         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x0df6b9c8      1       840      0x09e804e0         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x10c6a9b0      1       1392     0x0de052c8         dead   sun/reflect/DelegatingClassLoader@0x265e0248
0x108fb740      1       1392     0x0de052c8         dead   sun/reflect/DelegatingClassLoader@0x265e0248
...
total = 465     14242   31166840              N/A          alive=98, dead=367          N/A                42
Java 5

$ jmap -heap:format=b 2650
Attaching to process ID 2650, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_16-132
Unknown oop at 0x065ee230
Oop's klass is null
Finding object size using Printezis bits and skipping over...
heap written to heap.bin



$ du   -sh heap.bin
144M    heap.bin




                                                            43
Java 6


# jmap -dump:format=b,file=jboss.hprof 3421
Dumping heap to /root/jboss.hprof ...
Heap dump file created




                                              44
jstat
estatísticas mil da JVM




                          45
46
$ jstat
invalid argument count
Usage: jstat -help|-options
       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Definitions:
  <option>     An option reported by the -options option
  <vmid>       Virtual Machine Identifier. A vmid takes the following form:
                    <lvmid>[@<hostname>[:<port>]]
               Where <lvmid> is the local vm identifier for the target
               Java virtual machine, typically a process id; <hostname> is
               the name of the host running the target Java virtual machine;
               and <port> is the port number for the rmiregistry on the
               target host. See the jvmstat documentation for a more complete
               description of the Virtual Machine Identifier.
  <lines>      Number of samples between header lines.
  <interval>   Sampling interval. The following forms are allowed:
                   <n>["ms"|"s"]
               Where <n> is an integer and the suffix specifies the units as
               milliseconds("ms") or seconds("s"). The default units are "ms".
  <count>      Number of samples to take before terminating.
  -J<flag>     Pass <flag> directly to the runtime system.



                                                                             47
$ jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcpermcapacity
-gcutil
-printcompilation
                    48
Opções do jstat
•   class - estatísticas sobre os classloaders
•   compiler - estaitsticas sobre o compilador HotSpot
•   gc - estatisticas sobre a coleta de lixo
•   gccapcity - estatísticas sobre o espaçó total
•   gccause - resumo das estatísticas do GC
•   gcnew - estatísticas da new generation do GC
•   gcnewcapacity - estatísticas sobre a alocação de espaço da
    new generation do GC
•   gcold - estatísticas da old e permanent generation do GC
•   gcoldcapacity - estatísticas sobre a alocação de espaço da old e
    permanent generation do GC
•   gcutil - resumo das estatísticas do GC
•   printcompilation - estatísticas de compilação de métodos           49
$   jstat -class 2650
Loaded Bytes Unloaded             Bytes       Time
  9920 11187.2     43               36.7        79.70


$   jstat -compiler 2650
Compiled Failed Invalid            Time   FailedType FailedMethod
    3634      0       0             13.15          0


$   jstat -gc 2650
 S0C    S1C    S0U          S1U       EC         EU          OC            OU          PC     PU     YGC     YGCT     FGC           FGCT     GCT
2432.0 2432.0 254.2         0.0    19456.0    14714.8     190208.0      117606.8     44544.0 44336.3     154    6.897    8            32.184   39.08


$   jstat -gccapacity 2650
NGCMN     NGCMX      NGC     S0C   S1C         EC       OGCMN       OGCMX        OGC         OC       PGCMN    PGCMX      PGC        PC      YGC     FGC
14464.0   58240.0   24320.0 2432.0 2432.0    19456.0    116608.0    466048.0    190208.0   190208.0    8192.0 262144.0   44544.0   44544.0     154        8


$   jstat -gccause 2650
  S0       S1        E        O        P        YGC        YGCT       FGC      FGCT        GCT    LGCC                         GCC
 10.45     0.00     75.63    61.83    99.53       154       6.897        8     32.184      39.081 unknown GCCause              No GC


$   jstat -gcnew 2650
 S0C    S1C         S0U      S1U   TT MTT DSS              EC           EU        YGC       YGCT
2432.0 2432.0       254.2      0.0 15 15 1216.0          19456.0      14714.8       154      6.897




                                                                                                                                                     50
$   jstat -gcutil 6299
    S0     S1      E       O       P      YGC     YGCT     FGC         FGCT       GCT
    0.00 100.00   82.65   60.40   99.42     111    4.413      4        12.426     16.840



    •    S0 - % de uso do Survivor Space 0
    •    S1 - % de uso do Survivor Space 1
    •    E - % de uso do Eden Space
    •    O - % de uso da Old Generation
    •    P - % de uso da Permanent Generation
    •    YGC - # de GCs na Young Generation
    •    YGCT - Tempo total gasto em GCs na Young Generation
    •    FGC - # de Full GCs
    •    FGCT - Tempo total gasto em Full GCs
    •    GCT - Tempo total gasto em GCs (YGCT + FGCT)

        Perm                  Old                      S0         S1            Eden
                                                                                           51
52
53
54
55
56
57
58
59
60
61
62
jstack
stack trace de todas as threads da VM




                                        63
64
$ jstack
Usage: jstack [option] <pid>
                (to connect to a live java process)
   or jstack [option] <executable> <core>
                (to connect to a core file)
   or jstack [option] [server_id@]<remote server IP or hostname>
                (to connect to a remote debug server)

where option must be one of:
    -m to print both java and native frames (mixed mode)
    -h | -help to print this help message




                                                               65
$ jstack 6299
Attaching to process ID 6299, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_16-132
Thread t@3847: (state = BLOCKED)
 - java.lang.Object.wait(long) @bci=0 (Compiled frame; information may be imprecise)
 - sun.awt.AWTAutoShutdown.run() @bci=79, line=278 (Compiled frame)
 - java.lang.Thread.run() @bci=11, line=613 (Interpreted frame)


Thread t@4099: (state = IN_NATIVE)
 - java.net.PlainSocketImpl.socketAccept(java.net.SocketImpl) @bci=0 (Interpreted frame)
 - java.net.PlainSocketImpl.accept(java.net.SocketImpl) @bci=7, line=384 (Interpreted frame)
 - java.net.ServerSocket.implAccept(java.net.Socket) @bci=50, line=450 (Interpreted frame)
 - java.net.ServerSocket.accept() @bci=48, line=421 (Interpreted frame)
 - org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(java.net.ServerSocket)
@bci=1, line=61 (Interpreted frame)
 - org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run() @bci=47, line=310 (Interpreted frame)
 - java.lang.Thread.run() @bci=11, line=613 (Interpreted frame)


Thread t@4355: (state = IN_NATIVE)
 - java.net.PlainSocketImpl.socketAccept(java.net.SocketImpl) @bci=0 (Interpreted frame)
 - java.net.PlainSocketImpl.accept(java.net.SocketImpl) @bci=7, line=384 (Interpreted frame)
 - java.net.ServerSocket.implAccept(java.net.Socket) @bci=50, line=450 (Interpreted frame)
 - java.net.ServerSocket.accept() @bci=48, line=421 (Interpreted frame)
 - org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(java.net.ServerSocket)
@bci=1, line=61 (Interpreted frame)
 - org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run() @bci=47, line=310 (Interpreted frame)
 - java.lang.Thread.run() @bci=11, line=613 (Interpreted frame)


Thread t@4611: (state = BLOCKED)
 - java.lang.Object.wait(long) @bci=0 (Interpreted frame)
 - java.lang.Object.wait() @bci=2, line=474 (Interpreted frame)
 - org.jboss.bootstrap.AbstractServerImpl$LifeThread.run() @bci=11, line=789 (Interpreted frame) 66
jhat
navegação e busca no grafo de objetos




                                        67
68
# jhat
ERROR: No arguments supplied
Usage: jhat [-stack <bool>] [-refs <bool>] [-port <port>] [-baseline <file>] [-debug <int>]
[-version] [-h|-help] <file>

       -J<flag>          Pass <flag> directly to the runtime system. For
                         example, -J-mx512m to use a maximum heap size of 512MB
       -stack false:     Turn off tracking object allocation call stack.
       -refs false:      Turn off tracking of references to objects
       -port <port>:     Set the port for the HTTP server. Defaults to 7000
       -exclude <file>: Specify a file that lists data members that should
                         be excluded from the reachableFrom query.
       -baseline <file>: Specify a baseline object dump. Objects in
                         both heap dumps with the same ID and same class will
                         be marked as not being "new".
       -debug <int>:     Set debug level.
                           0: No debug output
                           1: Debug hprof file parsing
                           2: Debug hprof file parsing, no server
       -version          Report version number
       -h|-help          Print this help and exit
       <file>            The file to read




                                                                                          69
# jmap -dump:format=b,file=jboss.hprof 3421
Dumping heap to /root/jboss.hprof ...
Heap dump file created


# jhat jboss.hprof
Reading from /root/jboss.hprof...
Dump file created Fri May 22 05:09:16 BRT 2009
Snapshot read, resolving...
Resolving 464313 objects...
WARNING: Failed to resolve object id 0x85e94490 for field constantPoolOop (signature L)
...
WARNING: Failed to resolve object id 0x8571d198 for field constantPoolOop (signature L)
WARNING: Failed to resolve object id 0x8571a9a8 for field constantPoolOop (signature L)
Chasing references, expect 92
dots........................................................................................
....
Eliminating duplicate
references..................................................................................
..........
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.

                                                                                               70
71
72
73
74
75
jdb
java debuger




               76
$ jdb -listconnectors
Available connectors are:

  Connector: com.sun.jdi.CommandLineLaunch Transport: dt_socket
    description: Launches target using Sun Java VM command line and attaches to it

      Argument: home Default value: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
      description: Home directory of the SDK or runtime environment used to launch the application

      Argument: options (no default)
      description: Launched VM options

      Required Argument: main (no default)
      description: Main class and arguments, or if -jar is an option, the main jar file and arguments

      Argument: suspend Default value: true
      description: All threads will be suspended before execution of main

      Required Argument: quote Default value: "
      description: Character used to combine space-delimited text into a single command line argument

      Required Argument: vmexec Default value: java
      description: Name of the Java VM launcher
...




                                                                                                      77
$ jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=6299
Initializing jdb ...
>

> help
** command list **
connectors               -- list available connectors and transports in this VM

run [class [args]]       -- start execution of application's main class

threads [threadgroup]     --   list threads
thread <thread id>        --   set default thread
suspend [thread id(s)]    --   suspend threads (default: all)
resume [thread id(s)]     --   resume threads (default: all)
where [<thread id> | all] --   dump a thread's stack
wherei [<thread id> | all]--   dump a thread's stack, with pc info
up [n frames]             --   move up a thread's stack
down [n frames]           --   move down a thread's stack
kill <thread id> <expr>   --   kill a thread with the given exception object
interrupt <thread id>     --   interrupt a thread

print <expr>             --    print value of expression
dump <expr>              --    print all object information
eval <expr>              --    evaluate expression (same as print)
set <lvalue> = <expr>    --    assign new value to field/variable/array element
locals                   --    print all local variables in current stack frame
...


                                                                                  78
...
classes                   --   list   currently known classes
class <class id>          --   show   details of named class
methods <class id>        --   list   a class's methods
fields <class id>         --   list   a class's fields

threadgroups              -- list threadgroups
threadgroup <name>        -- set current threadgroup

stop in <class id>.<method>[(argument_type,...)]
                          -- set a breakpoint in a method
stop at <class id>:<line> -- set a breakpoint at a line
clear <class id>.<method>[(argument_type,...)]
                          -- clear a breakpoint in a method
clear <class id>:<line>   -- clear a breakpoint at a line
clear                     -- list breakpoints
catch [uncaught|caught|all] <class id>|<class pattern>
                          -- break when specified exception occurs
ignore [uncaught|caught|all] <class id>|<class pattern>
                          -- cancel 'catch' for the specified exception
watch [access|all] <class id>.<field name>
                          -- watch access/modifications to a field
unwatch [access|all] <class id>.<field name>
                          -- discontinue watching access/modifications to a field
trace methods [thread]    -- trace method entry and exit
untrace methods [thread] -- stop tracing method entry and exit
step                      -- execute current line
step up                   -- execute until the current method returns to its caller
stepi                     -- execute current instruction
next                      -- step one line (step OVER calls)
cont                      -- continue execution from breakpoint                   79
...
list [line number|method] -- print source code
use (or sourcepath) [source file path]
                          -- display or change the source path
exclude [<class pattern>, ... | "none"]
                          -- do not report step or method events for specified classes
classpath                 -- print classpath info from target VM

monitor <command>         --   execute command each time the program stops
monitor                   --   list monitors
unmonitor <monitor#>      --   delete a monitor
read <filename>           --   read and execute a command file

lock <expr>               -- print lock info for an object
threadlocks [thread id]   -- print lock info for a thread

pop                       -- pop the stack through and including the current frame
reenter                   -- same as pop, but current frame is reentered
redefine <class id> <class file name>
                          -- redefine the code for a class

disablegc <expr>          -- prevent garbage collection of an object
enablegc <expr>           -- permit garbage collection of an object




                                                                                         80
> threads
Group system:
  (java.lang.ref.Reference$ReferenceHandler)0x41   Reference Handler           unknown
  (java.lang.ref.Finalizer$FinalizerThread)0x40    Finalizer                   unknown
  (java.lang.Thread)0x3f                           Signal Dispatcher           running
  (java.lang.Thread)0x3a                           RMI TCP Accept-1098         running
  (java.lang.Thread)0x38                           RMI Reaper                  unknown
  (sun.misc.GC$Daemon)0x37                         GC Daemon                   unknown
  (java.lang.Thread)0x34                           RMI TCP Accept-1090         running
  (java.lang.Thread)0x33                           RMI TCP Accept-0            running
  (java.lang.Thread)0x32                           RMI RenewClean-[127.0.0.1:50475]     unknown
  (java.lang.Thread)0x31                           RMI LeaseChecker            sleeping
  (java.lang.Thread)0x22                           RMI TCP Accept-4444         running
Group main:
  (java.lang.Thread)0x3e                           DestroyJavaVM               running
  (java.lang.Thread)0x3                            AWT-AppKit                  running
Group jboss:
  (java.util.TimerThread)0x3d                      Timer-0                     unknown
  (java.util.TimerThread)0x3c                      Timer-Log4jService          unknown
...




                                                                                                  81
hprof
heap profiler




               82
Divirta-se com todas as ferramentas apresentadas.
                        Quem instanciou o objeto X?
                    Quem está referenciando o objeto X?
             Quantas threads ficam bloqueadas durante os testes?
                    Qual o pico de alocação da PermGen?
          Quais libs estão no classpath do classloader da aplicação?
     Qual a frequência de execução do GC na Young Gen? E na Old Gen?   83
P&R

More Related Content

Similar to Hotspot tools

Socket applications
Socket applicationsSocket applications
Socket applicationsJoão Moura
 
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Jean-Philippe BEMPEL
 
Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1상욱 송
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUGJorge Morales
 
Jvm tuning in a rush! - Lviv JUG
Jvm tuning in a rush! - Lviv JUGJvm tuning in a rush! - Lviv JUG
Jvm tuning in a rush! - Lviv JUGTomek Borek
 
CPAN 模組二三事
CPAN 模組二三事CPAN 模組二三事
CPAN 模組二三事Lin Yo-An
 
Jolokia - JMX on Capsaicin (Devoxx 2011)
Jolokia - JMX on Capsaicin (Devoxx 2011)Jolokia - JMX on Capsaicin (Devoxx 2011)
Jolokia - JMX on Capsaicin (Devoxx 2011)roland.huss
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展Leon Chen
 
Hadoop World 2011: Hadoop Troubleshooting 101 - Kate Ting - Cloudera
Hadoop World 2011: Hadoop Troubleshooting 101 - Kate Ting - ClouderaHadoop World 2011: Hadoop Troubleshooting 101 - Kate Ting - Cloudera
Hadoop World 2011: Hadoop Troubleshooting 101 - Kate Ting - ClouderaCloudera, Inc.
 
Garbage Collection of Java VM
Garbage Collection of Java VMGarbage Collection of Java VM
Garbage Collection of Java VMYongqiang Li
 
Jvm gc那点事
Jvm gc那点事Jvm gc那点事
Jvm gc那点事boboj
 
JBoss Enterprise Application Platform 6 Troubleshooting
JBoss Enterprise Application Platform 6 TroubleshootingJBoss Enterprise Application Platform 6 Troubleshooting
JBoss Enterprise Application Platform 6 TroubleshootingAlexandre Cavalcanti
 
OpenHFT: An Advanced Java Data Locality and IPC Transport Solution
OpenHFT: An Advanced Java Data Locality and IPC Transport SolutionOpenHFT: An Advanced Java Data Locality and IPC Transport Solution
OpenHFT: An Advanced Java Data Locality and IPC Transport SolutionBen Cotton
 
Java tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devJava tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devTomek Borek
 

Similar to Hotspot tools (20)

Socket applications
Socket applicationsSocket applications
Socket applications
 
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
 
Java performance
Java performanceJava performance
Java performance
 
Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1
 
Gc algorithms
Gc algorithmsGc algorithms
Gc algorithms
 
Taming The JVM
Taming The JVMTaming The JVM
Taming The JVM
 
Troubleshooting Java HotSpot VM
Troubleshooting Java HotSpot VMTroubleshooting Java HotSpot VM
Troubleshooting Java HotSpot VM
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUG
 
Principios básicos de Garbage Collector en Java
Principios básicos de Garbage Collector en JavaPrincipios básicos de Garbage Collector en Java
Principios básicos de Garbage Collector en Java
 
Jvm tuning in a rush! - Lviv JUG
Jvm tuning in a rush! - Lviv JUGJvm tuning in a rush! - Lviv JUG
Jvm tuning in a rush! - Lviv JUG
 
JVM Magic
JVM MagicJVM Magic
JVM Magic
 
CPAN 模組二三事
CPAN 模組二三事CPAN 模組二三事
CPAN 模組二三事
 
Jolokia - JMX on Capsaicin (Devoxx 2011)
Jolokia - JMX on Capsaicin (Devoxx 2011)Jolokia - JMX on Capsaicin (Devoxx 2011)
Jolokia - JMX on Capsaicin (Devoxx 2011)
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展
 
Hadoop World 2011: Hadoop Troubleshooting 101 - Kate Ting - Cloudera
Hadoop World 2011: Hadoop Troubleshooting 101 - Kate Ting - ClouderaHadoop World 2011: Hadoop Troubleshooting 101 - Kate Ting - Cloudera
Hadoop World 2011: Hadoop Troubleshooting 101 - Kate Ting - Cloudera
 
Garbage Collection of Java VM
Garbage Collection of Java VMGarbage Collection of Java VM
Garbage Collection of Java VM
 
Jvm gc那点事
Jvm gc那点事Jvm gc那点事
Jvm gc那点事
 
JBoss Enterprise Application Platform 6 Troubleshooting
JBoss Enterprise Application Platform 6 TroubleshootingJBoss Enterprise Application Platform 6 Troubleshooting
JBoss Enterprise Application Platform 6 Troubleshooting
 
OpenHFT: An Advanced Java Data Locality and IPC Transport Solution
OpenHFT: An Advanced Java Data Locality and IPC Transport SolutionOpenHFT: An Advanced Java Data Locality and IPC Transport Solution
OpenHFT: An Advanced Java Data Locality and IPC Transport Solution
 
Java tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devJava tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy dev
 

More from SEA Tecnologia

Loomio how to Series - Working on a Discussion
Loomio how to Series - Working on a DiscussionLoomio how to Series - Working on a Discussion
Loomio how to Series - Working on a DiscussionSEA Tecnologia
 
Loomio how to Series - Creating a new Group of People
Loomio how to Series - Creating a new Group of PeopleLoomio how to Series - Creating a new Group of People
Loomio how to Series - Creating a new Group of PeopleSEA Tecnologia
 
Loomio how to Series - Creating a new Discussion
Loomio how to Series - Creating a new DiscussionLoomio how to Series - Creating a new Discussion
Loomio how to Series - Creating a new DiscussionSEA Tecnologia
 
Gerentes em Crise existencial - Existimos no Universo Ágil?
Gerentes em Crise existencial - Existimos no Universo Ágil?Gerentes em Crise existencial - Existimos no Universo Ágil?
Gerentes em Crise existencial - Existimos no Universo Ágil?SEA Tecnologia
 
O curioso caso de Náutilus Button
O curioso caso de Náutilus ButtonO curioso caso de Náutilus Button
O curioso caso de Náutilus ButtonSEA Tecnologia
 
Contratos de desenvolvimento de software para governo blue pill or red pill?
Contratos de desenvolvimento de software para governo  blue pill or red pill?Contratos de desenvolvimento de software para governo  blue pill or red pill?
Contratos de desenvolvimento de software para governo blue pill or red pill?SEA Tecnologia
 
Os benefícios e desafios da participação pública digital
Os benefícios e desafios da participação pública digitalOs benefícios e desafios da participação pública digital
Os benefícios e desafios da participação pública digitalSEA Tecnologia
 
A escola do século XXI deve ser ágil, enxuta e empreendedora.
A escola do século XXI deve ser ágil, enxuta e empreendedora.A escola do século XXI deve ser ágil, enxuta e empreendedora.
A escola do século XXI deve ser ágil, enxuta e empreendedora.SEA Tecnologia
 
Open data, scraping e thacks com Software Livre
Open data, scraping e thacks com Software LivreOpen data, scraping e thacks com Software Livre
Open data, scraping e thacks com Software LivreSEA Tecnologia
 
Agilidade dos projetos à empresa, uma história de Intracontágio
Agilidade dos projetos à empresa, uma história de IntracontágioAgilidade dos projetos à empresa, uma história de Intracontágio
Agilidade dos projetos à empresa, uma história de IntracontágioSEA Tecnologia
 
Roadshow Brasília Novas funcionalidades Liferay 6
Roadshow Brasília Novas funcionalidades Liferay 6Roadshow Brasília Novas funcionalidades Liferay 6
Roadshow Brasília Novas funcionalidades Liferay 6SEA Tecnologia
 
Roadshow Liferay no Brasil 2010
Roadshow Liferay no Brasil 2010Roadshow Liferay no Brasil 2010
Roadshow Liferay no Brasil 2010SEA Tecnologia
 
Sem tesão não há solução
Sem tesão não há soluçãoSem tesão não há solução
Sem tesão não há soluçãoSEA Tecnologia
 
Empreendimentos em Rede
Empreendimentos em RedeEmpreendimentos em Rede
Empreendimentos em RedeSEA Tecnologia
 

More from SEA Tecnologia (20)

Loomio how to Series - Working on a Discussion
Loomio how to Series - Working on a DiscussionLoomio how to Series - Working on a Discussion
Loomio how to Series - Working on a Discussion
 
Loomio how to Series - Creating a new Group of People
Loomio how to Series - Creating a new Group of PeopleLoomio how to Series - Creating a new Group of People
Loomio how to Series - Creating a new Group of People
 
Loomio how to Series - Creating a new Discussion
Loomio how to Series - Creating a new DiscussionLoomio how to Series - Creating a new Discussion
Loomio how to Series - Creating a new Discussion
 
Gerentes em Crise existencial - Existimos no Universo Ágil?
Gerentes em Crise existencial - Existimos no Universo Ágil?Gerentes em Crise existencial - Existimos no Universo Ágil?
Gerentes em Crise existencial - Existimos no Universo Ágil?
 
O curioso caso de Náutilus Button
O curioso caso de Náutilus ButtonO curioso caso de Náutilus Button
O curioso caso de Náutilus Button
 
Contratos de desenvolvimento de software para governo blue pill or red pill?
Contratos de desenvolvimento de software para governo  blue pill or red pill?Contratos de desenvolvimento de software para governo  blue pill or red pill?
Contratos de desenvolvimento de software para governo blue pill or red pill?
 
#Fail
#Fail#Fail
#Fail
 
Agilidade no Governo
Agilidade no GovernoAgilidade no Governo
Agilidade no Governo
 
Os benefícios e desafios da participação pública digital
Os benefícios e desafios da participação pública digitalOs benefícios e desafios da participação pública digital
Os benefícios e desafios da participação pública digital
 
A escola do século XXI deve ser ágil, enxuta e empreendedora.
A escola do século XXI deve ser ágil, enxuta e empreendedora.A escola do século XXI deve ser ágil, enxuta e empreendedora.
A escola do século XXI deve ser ágil, enxuta e empreendedora.
 
Lean Startup
Lean StartupLean Startup
Lean Startup
 
Open Data
Open DataOpen Data
Open Data
 
Open data, scraping e thacks com Software Livre
Open data, scraping e thacks com Software LivreOpen data, scraping e thacks com Software Livre
Open data, scraping e thacks com Software Livre
 
Agilidade dos projetos à empresa, uma história de Intracontágio
Agilidade dos projetos à empresa, uma história de IntracontágioAgilidade dos projetos à empresa, uma história de Intracontágio
Agilidade dos projetos à empresa, uma história de Intracontágio
 
Roadshow Brasília Novas funcionalidades Liferay 6
Roadshow Brasília Novas funcionalidades Liferay 6Roadshow Brasília Novas funcionalidades Liferay 6
Roadshow Brasília Novas funcionalidades Liferay 6
 
Roadshow Liferay no Brasil 2010
Roadshow Liferay no Brasil 2010Roadshow Liferay no Brasil 2010
Roadshow Liferay no Brasil 2010
 
Sem tesão não há solução
Sem tesão não há soluçãoSem tesão não há solução
Sem tesão não há solução
 
Empreendimentos em Rede
Empreendimentos em RedeEmpreendimentos em Rede
Empreendimentos em Rede
 
Java Profiling Tools
Java Profiling ToolsJava Profiling Tools
Java Profiling Tools
 
Misc Monitoring Tools
Misc Monitoring ToolsMisc Monitoring Tools
Misc Monitoring Tools
 

Recently uploaded

Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...DianaGray10
 
UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2DianaGray10
 
Planetek Italia Srl - Corporate Profile Brochure
Planetek Italia Srl - Corporate Profile BrochurePlanetek Italia Srl - Corporate Profile Brochure
Planetek Italia Srl - Corporate Profile BrochurePlanetek Italia Srl
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024Brian Pichman
 
Flow Control | Block Size | ST Min | First Frame
Flow Control | Block Size | ST Min | First FrameFlow Control | Block Size | ST Min | First Frame
Flow Control | Block Size | ST Min | First FrameKapil Thakar
 
Introduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationIntroduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationKnoldus Inc.
 
Stobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
Stobox 4: Revolutionizing Investment in Real-World Assets Through TokenizationStobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
Stobox 4: Revolutionizing Investment in Real-World Assets Through TokenizationStobox
 
Automation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsAutomation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsDianaGray10
 
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechWebinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechProduct School
 
3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud DataEric D. Schabell
 
Patch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updatePatch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updateadam112203
 
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024Alkin Tezuysal
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4DianaGray10
 
The New Cloud World Order Is FinOps (Slideshow)
The New Cloud World Order Is FinOps (Slideshow)The New Cloud World Order Is FinOps (Slideshow)
The New Cloud World Order Is FinOps (Slideshow)codyslingerland1
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxNeo4j
 
.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptxHansamali Gamage
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applicationsnooralam814309
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInThousandEyes
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Libraryshyamraj55
 

Recently uploaded (20)

Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...
 
UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2
 
Planetek Italia Srl - Corporate Profile Brochure
Planetek Italia Srl - Corporate Profile BrochurePlanetek Italia Srl - Corporate Profile Brochure
Planetek Italia Srl - Corporate Profile Brochure
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024
 
Flow Control | Block Size | ST Min | First Frame
Flow Control | Block Size | ST Min | First FrameFlow Control | Block Size | ST Min | First Frame
Flow Control | Block Size | ST Min | First Frame
 
Introduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationIntroduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its application
 
Stobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
Stobox 4: Revolutionizing Investment in Real-World Assets Through TokenizationStobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
Stobox 4: Revolutionizing Investment in Real-World Assets Through Tokenization
 
Automation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsAutomation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projects
 
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechWebinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
 
3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data
 
Patch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updatePatch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 update
 
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4
 
The New Cloud World Order Is FinOps (Slideshow)
The New Cloud World Order Is FinOps (Slideshow)The New Cloud World Order Is FinOps (Slideshow)
The New Cloud World Order Is FinOps (Slideshow)
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
 
.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applications
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Library
 

Hotspot tools

  • 1. Ferramentas da Hotspot
  • 2. 2
  • 3. Agenda • jps • jstack • jinfo • jhat • jmap • jdb • jstat • hprof http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/tooldescr.html 3
  • 5. 5
  • 6. $ jps -h illegal argument: -h usage: jps [-help] jps [-q] [-mlvV] [<hostid>] Definitions: <hostid>: <hostname>[:<port>] 6
  • 7. $ ps | grep -i java 4008 p2 S+ 0:00.02 /bin/sh /Users/alegomes/JavaTools/jopr-server-2.2.0/jbossas/bin/ run.sh -P / 4017 p2 S+ 33:21.61 /Library/Java/Home/bin/java -Dprogram.name=run.sh -Dapp.name=rhq- server -Xm 11989 p4 R+ 0:00.00 grep -i java 840 p5 S+ 7:10.01 /Library/Java/Home/bin/java -Dprogram.name=run.sh -Xms128m -Xmx512m -Dsun.r 7
  • 8. $ ps | grep -i java 4008 p2 S+ 0:00.02 /bin/sh /Users/alegomes/JavaTools/jopr-server-2.2.0/jbossas/bin/ run.sh -P / 4017 p2 S+ 33:21.61 /Library/Java/Home/bin/java -Dprogram.name=run.sh -Dapp.name=rhq- server -Xm 11989 p4 R+ 0:00.00 grep -i java 840 p5 S+ 7:10.01 /Library/Java/Home/bin/java -Dprogram.name=run.sh -Xms128m -Xmx512m -Dsun.r 7
  • 9. $ jps 2989 2614 Jps 3614 $ jps -v 2617 Jps -Dapplication.home=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/ Home -Xms8m 2989 -Xbootclasspath/a:/System/Library/PrivateFrameworks/ JavaApplicationLauncher.framework/Resources/LauncherSupport.jar - Dapple.laf.useScreenMenuBar=true -Dapple.awt.showGrowBox=true - Dapple.awt.antialiasing=false -Dcom.apple.mrj.application.apple.menu.about.name=FreeMind -Dcom.apple.mrj.application.live-resize=true -Dcom.apple.smallTabs=false - Dapple.awt.textantialiasing=false 3614 -Xbootclasspath/p:/Applications/Firefox 3.0.1.app/Contents/MacOS/plugins/ MRJPlugin.plugin/Contents/MacOS/MRJPlugin.jar -Dnetscape.oji.plugin.home=/Applications/ Firefox 3.0.1.app/Contents/MacOS/plugins/MRJPlugin.plugin/Contents/MacOS -Xmx96m - Djavaplugin.maxHeapSize=96m -Xbootclasspath/a:/System/Library/Frameworks/ JavaVM.framework/Versions/1.5/Home/lib/deploy.jar:/System/Library/Frameworks/ JavaVM.framework/Versions/1.5/Home/lib/plugin.jar:/System/Library/Frameworks/ JavaVM.framework/Versions/1.5/Home/lib/ext/apple_provider.jar -Xbootclasspath/p:/ Applications/Firefox 3.0.1.app/Contents/MacOS/plugins/JavaEmbeddingPlugin.bundle/ Contents/Resources/Java/JavaEmbeddingPlugin.jar -Djep.pluginhome=/Applications/Firefox 3.0.1.app/Contents/MacOS/plugins/JavaEmbeddingPlugin.bundle -Djep.version=0.9.6.4 - Djep.version.applet=true -Djep.debug.visibility.applet=true - Djep.debug.release.applet=true -Djep.debug.updates.applet=true -DtrustProxy=true vfprintf 8
  • 11. 10
  • 12. $ jinfo Usage: jinfo [option] <pid> (to connect to a live java process) or jinfo [option] <executable> <core> (to connect to a core file) or jinfo [option] [server_id@]<remote server IP or hostname> (to connect to a remote debug server) where option must be one of: -flags to print VM flags -sysprops to print Java System properties <no option> to print both of the above -h | -help to print this help message 11
  • 13. $ jinfo 2650 Attaching to process ID 2650, please wait... Debugger attached successfully. Client compiler detected. JVM version is 1.5.0_16-132 Java System Properties: java.vendor = Apple Computer, Inc. sun.java.launcher = SUN_STANDARD sun.management.compiler = HotSpot Client Compiler os.name = Mac OS X sun.boot.class.path = /Users/alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed/activation.jar:/Users/ alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed/jaxb-api.jar:/Users/alegomes/jbtun/app/ jboss-5.0.0.GA/bin/../lib/endorsed/resolver.jar:/Users/alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/ endorsed/serializer.jar:/Users/alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed/stax-api.jar:/Users/ alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed/xalan.jar:/Users/alegomes/jbtun/app/jboss-5.0.0.GA/ bin/../lib/endorsed/xercesImpl.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/ classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/ui.jar:/System/Library/ Frameworks/JavaVM.framework/Versions/1.5.0/Classes/laf.jar:/System/Library/Frameworks/JavaVM.framework/ Versions/1.5.0/Classes/sunrsasign.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/ jsse.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/jce.jar:/System/Library/ Frameworks/JavaVM.framework/Versions/1.5.0/Classes/charsets.jar java.vm.specification.vendor = Sun Microsystems Inc. java.runtime.version = 1.5.0_16-b06-275 org.apache.catalina.core.StandardHost.autoDeploy = false user.name = alegomes jboss.remoting.version = 22 jboss.bind.address = 127.0.0.1 jboss.messaging.connector.bisocket.port = 4457 awt.nativeDoubleBuffering = true tomcat.util.buf.StringCache.byte.enabled = true jboss.home.dir = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA com.arjuna.common.util.logging.DebugLevel = 0x00000000 java.naming.factory.initial = org.jnp.interfaces.NamingContextFactory user.language = en sun.boot.library.path = /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries com.arjuna.ats.jta.lastResourceOptimisationInterface = org.jboss.tm.LastResource jboss.home.url = file:/Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/ java.version = 1.5.0_16omes$ 12
  • 14. (...) java.rmi.server.codebase = http://127.0.0.1:8083/ java.io.tmpdir = /tmp java.vendor.url.bug = http://developer.apple.com/java/ jboss.server.data.dir = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/server/ default/data java.rmi.server.hostname = 127.0.0.1 jboss.vfs.forceCopy = true os.arch = ppc java.awt.graphicsenv = apple.awt.CGraphicsEnvironment org.apache.catalina.core.StandardHost.deployXML = false java.ext.dirs = /Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/ Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext PROPERTIES_FILE = tsmx.properties mrj.version = 1040.1.5.0_16-275 user.dir = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/bin org.apache.catalina.core.StandardHost.deployOnStartup = false apple.awt.graphics.UseQuartz = true line.separator = java.vm.name = Java HotSpot(TM) Client VM jboss.server.base.dir = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/server org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger com.arjuna.common.util.logging.FacilityLevel = 0xffffffff jboss.server.base.url = file:/Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/ server/ javax.management.builder.initial = org.jboss.mx.server.MBeanServerBuilderImpl file.encoding = MacRoman org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP = true catalina.ext.dirs = /Volumes/Data/Documents/sea/edu/jboss_tuning/app/jboss-5.0.0.GA/server/default/ lib java.specification.version = 1.5 jboss.server.name = default VM Flags: -Dprogram.name=run.sh -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true - Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 - Djava.endorsed.dirs=/Users/alegomes/jbtun/app/jboss-5.0.0.GA/bin/../lib/endorsed 13
  • 16. Regra Geral do GC 15 http://chaoticjava.com/posts/how-does-garbage-collection-work/
  • 17. Problema As memórias estão cada vez maiores. 16
  • 19. Idéia! 18
  • 20. GC Geracional Old Young 19
  • 21. GC Geracional Old Young alta mortalidade GC frequente espaço menor 19
  • 22. GC Geracional Old Young baixa mortalidade alta mortalidade GC não tão frequente GC frequente espaço maior espaço menor 19
  • 23. GC Geracional Perm Old Young 20
  • 24. GC Geracional Perm Old Young Pouco espaço Coleta rápida Muitas coletas 20
  • 25. GC Geracional Perm Old Young Muito espaço Pouco espaço Coleta demorada Coleta rápida Poucas coletas Muitas coletas 20
  • 26. GC Geracional Perm Old Young Dados Muito espaço Pouco espaço permanentes. Coleta demorada Coleta rápida Poucas coletas Muitas coletas Coletados uma vez na vida e outra na morte 20
  • 27. Compactação processo de alto custo 21
  • 28. Compactação defragmentação mem frag cópia deleção cópia 22
  • 29. Compactação defragmentação mem frag cópia deleção cópia 23
  • 30. Compactação defragmentação mem frag cópia deleção cópia 24
  • 31. Compactação defragmentação mem frag cópia deleção cópia 25
  • 32. Copy menos custoso que a compactação 26
  • 33. Copy defragmentação S0 S1 S0 cópia S1 27
  • 34. Copy Na Young Generation, faz-se a cópia de objetos ao invés da compactação. Este mecanismo é eficiente pois atinge-se a defragmentação da memória sem a necessidade de varrê-la. 28
  • 35. Perm Old S0 S1 Eden 29
  • 36. Perm Old S0 S1 Eden Áreas temporárias para cópia de objetos 29
  • 38. 31
  • 40. 32 http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html
  • 41. Promoção 33 http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html
  • 42. Mark Sweep 34 http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html
  • 43. Resumo 35
  • 45. 37
  • 46. $ jmap Usage: jmap [option] <pid> (to connect to a live java process) or jmap [option] <executable> <core> (to connect to a core file) or jmap [option] [server_id@]<remote server IP or hostname> (to connect to a remote debug server) where option must be one of: <no option> same as -heap -heap to print java heap summary -heap:format=b|x to dump java heap in hprof binary format -histo to print histogram of java object heap -permstat to print permanent generation statistics -h | -help to print this help message 38
  • 47. $ jmap -heap 2650 Attaching to process ID 2650, please wait... Debugger attached successfully. Client compiler detected. JVM version is 1.5.0_16-132 using thread-local object allocation. Mark Sweep Compact GC Heap Configuration: MinHeapFreeRatio = 40 MaxHeapFreeRatio = 70 MaxHeapSize = 536870912 (512.0MB) NewSize = 655360 (0.625MB) MaxNewSize = 4294836224 (4095.875MB) OldSize = 1441792 (1.375MB) NewRatio = 8 SurvivorRatio = 8 PermSize = 8388608 (8.0MB) MaxPermSize = 268435456 (256.0MB) 39
  • 48. (...) Heap Usage: New Generation (Eden + 1 Survivor Space): capacity = 22413312 (21.375MB) used = 19454264 (18.55303192138672MB) free = 2959048 (2.8219680786132812MB) 86.79781015853436% used Eden Space: capacity = 19922944 (19.0MB) used = 19174288 (18.286026000976562MB) free = 748656 (0.7139739990234375MB) 96.24224211040296% used From Space: capacity = 2490368 (2.375MB) used = 279976 (0.26700592041015625MB) free = 2210392 (2.1079940795898438MB) 11.242354543585526% used To Space: capacity = 2490368 (2.375MB) used = 0 (0.0MB) free = 2490368 (2.375MB) 0.0% used tenured generation: capacity = 194772992 (185.75MB) used = 120429336 (114.8503646850586MB) free = 74343656 (70.8996353149414MB) 61.83061355857798% used Perm Generation: capacity = 45613056 (43.5MB) used = 45396720 (43.29368591308594MB) free = 216336 (0.2063140869140625MB) 99.5257147427263% used 40
  • 49. $ jmap -histo 2650 Object Histogram: Size Count Class description ------------------------------------------------------- 26114008 232479 char[] 15697136 21720 byte[] 13056704 103094 * ConstMethodKlass 9788712 407863 java.lang.String 8013376 250418 java.util.TreeMap$Entry 6704152 147510 * SymbolKlass 5777192 103094 * MethodKlass 5671208 62558 java.util.HashMap$Entry[] 5589144 232881 java.util.HashMap$Entry 5561696 9877 * ConstantPoolKlass 4230480 9877 * InstanceKlassKlass 3768000 47100 java.lang.reflect.Method 3234112 44591 java.lang.Object[] 3134336 8290 * ConstantPoolCacheKlass 3089048 15456 int[] 2513760 31422 java.util.zip.ZipEntry 2375560 59389 java.util.HashMap 2267480 56687 java.util.TreeMap 2210048 69064 java.util.concurrent.ConcurrentHashMap$Segment 1673216 26144 org.jboss.mx.server.InvocationContext 1658616 69109 java.util.concurrent.locks.ReentrantLock$NonfairSync 1517520 31615 org.jboss.virtual.plugins.context.zip.ZipEntryHandler 1496760 69219 java.util.concurrent.ConcurrentHashMap$HashEntry[] 1442960 90185 org.jboss.logging.Logger 1442960 90185 org.jboss.logging.log4j.Log4jLoggerPlugin 41
  • 50. $ jmap -permstat 2650 Attaching to process ID 2650, please wait... Debugger attached successfully. Client compiler detected. JVM version is 1.5.0_16-132 finding class loader instances ..Unknown oop at 0x065ee230 Oop's klass is null Finding object size using Printezis bits and skipping over... done. computing per loader stat ..done. please wait.. computing liveness....................................................................................Unknown oop at 0xf23b7c68 Oop's klass is 0x075bd890 Liveness analysis: WARNING: UnknownOopException for oop at 0xf23b7c68 LivenessAnalysis: WARNING: sun.jvm.hotspot.utilities.AssertionFailure: should not reach here during traversal Liveness analysis: WARNING: AddressException at 0x87859397 while traversing oop at 0x87859393 done. class_loader classes bytes parent_loader alive? type <bootstrap> 2740 5755040 null live <internal> 0x0db29710 3 4616 null live org/jboss/classloader/spi/base/ BaseClassLoader@0x26ddb718 0x102d5e68 1 1392 0x0b1572a8 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x0a706728 1 1392 0x09e804e0 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x0d7f8858 1 1392 0x0b1572a8 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x0dc9c290 5 21608 null live org/jboss/classloader/spi/base/ BaseClassLoader@0x26ddb718 0x0f0380a0 1 1392 0x09e804e0 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x0f4e31f0 1 1392 0x0dc9bf70 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x0df37b30 1 1392 0x09e804e0 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x09f38480 1 840 null dead sun/reflect/DelegatingClassLoader@0x265e0248 0x0e74a6a0 1 1392 0x0b1572a8 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x0df6b9c8 1 840 0x09e804e0 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x10c6a9b0 1 1392 0x0de052c8 dead sun/reflect/DelegatingClassLoader@0x265e0248 0x108fb740 1 1392 0x0de052c8 dead sun/reflect/DelegatingClassLoader@0x265e0248 ... total = 465 14242 31166840 N/A alive=98, dead=367 N/A 42
  • 51. Java 5 $ jmap -heap:format=b 2650 Attaching to process ID 2650, please wait... Debugger attached successfully. Client compiler detected. JVM version is 1.5.0_16-132 Unknown oop at 0x065ee230 Oop's klass is null Finding object size using Printezis bits and skipping over... heap written to heap.bin $ du -sh heap.bin 144M heap.bin 43
  • 52. Java 6 # jmap -dump:format=b,file=jboss.hprof 3421 Dumping heap to /root/jboss.hprof ... Heap dump file created 44
  • 54. 46
  • 55. $ jstat invalid argument count Usage: jstat -help|-options jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]] Definitions: <option> An option reported by the -options option <vmid> Virtual Machine Identifier. A vmid takes the following form: <lvmid>[@<hostname>[:<port>]] Where <lvmid> is the local vm identifier for the target Java virtual machine, typically a process id; <hostname> is the name of the host running the target Java virtual machine; and <port> is the port number for the rmiregistry on the target host. See the jvmstat documentation for a more complete description of the Virtual Machine Identifier. <lines> Number of samples between header lines. <interval> Sampling interval. The following forms are allowed: <n>["ms"|"s"] Where <n> is an integer and the suffix specifies the units as milliseconds("ms") or seconds("s"). The default units are "ms". <count> Number of samples to take before terminating. -J<flag> Pass <flag> directly to the runtime system. 47
  • 57. Opções do jstat • class - estatísticas sobre os classloaders • compiler - estaitsticas sobre o compilador HotSpot • gc - estatisticas sobre a coleta de lixo • gccapcity - estatísticas sobre o espaçó total • gccause - resumo das estatísticas do GC • gcnew - estatísticas da new generation do GC • gcnewcapacity - estatísticas sobre a alocação de espaço da new generation do GC • gcold - estatísticas da old e permanent generation do GC • gcoldcapacity - estatísticas sobre a alocação de espaço da old e permanent generation do GC • gcutil - resumo das estatísticas do GC • printcompilation - estatísticas de compilação de métodos 49
  • 58. $ jstat -class 2650 Loaded Bytes Unloaded Bytes Time 9920 11187.2 43 36.7 79.70 $ jstat -compiler 2650 Compiled Failed Invalid Time FailedType FailedMethod 3634 0 0 13.15 0 $ jstat -gc 2650 S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT 2432.0 2432.0 254.2 0.0 19456.0 14714.8 190208.0 117606.8 44544.0 44336.3 154 6.897 8 32.184 39.08 $ jstat -gccapacity 2650 NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC PGCMN PGCMX PGC PC YGC FGC 14464.0 58240.0 24320.0 2432.0 2432.0 19456.0 116608.0 466048.0 190208.0 190208.0 8192.0 262144.0 44544.0 44544.0 154 8 $ jstat -gccause 2650 S0 S1 E O P YGC YGCT FGC FGCT GCT LGCC GCC 10.45 0.00 75.63 61.83 99.53 154 6.897 8 32.184 39.081 unknown GCCause No GC $ jstat -gcnew 2650 S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT 2432.0 2432.0 254.2 0.0 15 15 1216.0 19456.0 14714.8 154 6.897 50
  • 59. $ jstat -gcutil 6299 S0 S1 E O P YGC YGCT FGC FGCT GCT 0.00 100.00 82.65 60.40 99.42 111 4.413 4 12.426 16.840 • S0 - % de uso do Survivor Space 0 • S1 - % de uso do Survivor Space 1 • E - % de uso do Eden Space • O - % de uso da Old Generation • P - % de uso da Permanent Generation • YGC - # de GCs na Young Generation • YGCT - Tempo total gasto em GCs na Young Generation • FGC - # de Full GCs • FGCT - Tempo total gasto em Full GCs • GCT - Tempo total gasto em GCs (YGCT + FGCT) Perm Old S0 S1 Eden 51
  • 60. 52
  • 61. 53
  • 62. 54
  • 63. 55
  • 64. 56
  • 65. 57
  • 66. 58
  • 67. 59
  • 68. 60
  • 69. 61
  • 70. 62
  • 71. jstack stack trace de todas as threads da VM 63
  • 72. 64
  • 73. $ jstack Usage: jstack [option] <pid> (to connect to a live java process) or jstack [option] <executable> <core> (to connect to a core file) or jstack [option] [server_id@]<remote server IP or hostname> (to connect to a remote debug server) where option must be one of: -m to print both java and native frames (mixed mode) -h | -help to print this help message 65
  • 74. $ jstack 6299 Attaching to process ID 6299, please wait... Debugger attached successfully. Client compiler detected. JVM version is 1.5.0_16-132 Thread t@3847: (state = BLOCKED) - java.lang.Object.wait(long) @bci=0 (Compiled frame; information may be imprecise) - sun.awt.AWTAutoShutdown.run() @bci=79, line=278 (Compiled frame) - java.lang.Thread.run() @bci=11, line=613 (Interpreted frame) Thread t@4099: (state = IN_NATIVE) - java.net.PlainSocketImpl.socketAccept(java.net.SocketImpl) @bci=0 (Interpreted frame) - java.net.PlainSocketImpl.accept(java.net.SocketImpl) @bci=7, line=384 (Interpreted frame) - java.net.ServerSocket.implAccept(java.net.Socket) @bci=50, line=450 (Interpreted frame) - java.net.ServerSocket.accept() @bci=48, line=421 (Interpreted frame) - org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(java.net.ServerSocket) @bci=1, line=61 (Interpreted frame) - org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run() @bci=47, line=310 (Interpreted frame) - java.lang.Thread.run() @bci=11, line=613 (Interpreted frame) Thread t@4355: (state = IN_NATIVE) - java.net.PlainSocketImpl.socketAccept(java.net.SocketImpl) @bci=0 (Interpreted frame) - java.net.PlainSocketImpl.accept(java.net.SocketImpl) @bci=7, line=384 (Interpreted frame) - java.net.ServerSocket.implAccept(java.net.Socket) @bci=50, line=450 (Interpreted frame) - java.net.ServerSocket.accept() @bci=48, line=421 (Interpreted frame) - org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(java.net.ServerSocket) @bci=1, line=61 (Interpreted frame) - org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run() @bci=47, line=310 (Interpreted frame) - java.lang.Thread.run() @bci=11, line=613 (Interpreted frame) Thread t@4611: (state = BLOCKED) - java.lang.Object.wait(long) @bci=0 (Interpreted frame) - java.lang.Object.wait() @bci=2, line=474 (Interpreted frame) - org.jboss.bootstrap.AbstractServerImpl$LifeThread.run() @bci=11, line=789 (Interpreted frame) 66
  • 75. jhat navegação e busca no grafo de objetos 67
  • 76. 68
  • 77. # jhat ERROR: No arguments supplied Usage: jhat [-stack <bool>] [-refs <bool>] [-port <port>] [-baseline <file>] [-debug <int>] [-version] [-h|-help] <file> -J<flag> Pass <flag> directly to the runtime system. For example, -J-mx512m to use a maximum heap size of 512MB -stack false: Turn off tracking object allocation call stack. -refs false: Turn off tracking of references to objects -port <port>: Set the port for the HTTP server. Defaults to 7000 -exclude <file>: Specify a file that lists data members that should be excluded from the reachableFrom query. -baseline <file>: Specify a baseline object dump. Objects in both heap dumps with the same ID and same class will be marked as not being "new". -debug <int>: Set debug level. 0: No debug output 1: Debug hprof file parsing 2: Debug hprof file parsing, no server -version Report version number -h|-help Print this help and exit <file> The file to read 69
  • 78. # jmap -dump:format=b,file=jboss.hprof 3421 Dumping heap to /root/jboss.hprof ... Heap dump file created # jhat jboss.hprof Reading from /root/jboss.hprof... Dump file created Fri May 22 05:09:16 BRT 2009 Snapshot read, resolving... Resolving 464313 objects... WARNING: Failed to resolve object id 0x85e94490 for field constantPoolOop (signature L) ... WARNING: Failed to resolve object id 0x8571d198 for field constantPoolOop (signature L) WARNING: Failed to resolve object id 0x8571a9a8 for field constantPoolOop (signature L) Chasing references, expect 92 dots........................................................................................ .... Eliminating duplicate references.................................................................................. .......... Snapshot resolved. Started HTTP server on port 7000 Server is ready. 70
  • 79. 71
  • 80. 72
  • 81. 73
  • 82. 74
  • 83. 75
  • 85. $ jdb -listconnectors Available connectors are: Connector: com.sun.jdi.CommandLineLaunch Transport: dt_socket description: Launches target using Sun Java VM command line and attaches to it Argument: home Default value: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home description: Home directory of the SDK or runtime environment used to launch the application Argument: options (no default) description: Launched VM options Required Argument: main (no default) description: Main class and arguments, or if -jar is an option, the main jar file and arguments Argument: suspend Default value: true description: All threads will be suspended before execution of main Required Argument: quote Default value: " description: Character used to combine space-delimited text into a single command line argument Required Argument: vmexec Default value: java description: Name of the Java VM launcher ... 77
  • 86. $ jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=6299 Initializing jdb ... > > help ** command list ** connectors -- list available connectors and transports in this VM run [class [args]] -- start execution of application's main class threads [threadgroup] -- list threads thread <thread id> -- set default thread suspend [thread id(s)] -- suspend threads (default: all) resume [thread id(s)] -- resume threads (default: all) where [<thread id> | all] -- dump a thread's stack wherei [<thread id> | all]-- dump a thread's stack, with pc info up [n frames] -- move up a thread's stack down [n frames] -- move down a thread's stack kill <thread id> <expr> -- kill a thread with the given exception object interrupt <thread id> -- interrupt a thread print <expr> -- print value of expression dump <expr> -- print all object information eval <expr> -- evaluate expression (same as print) set <lvalue> = <expr> -- assign new value to field/variable/array element locals -- print all local variables in current stack frame ... 78
  • 87. ... classes -- list currently known classes class <class id> -- show details of named class methods <class id> -- list a class's methods fields <class id> -- list a class's fields threadgroups -- list threadgroups threadgroup <name> -- set current threadgroup stop in <class id>.<method>[(argument_type,...)] -- set a breakpoint in a method stop at <class id>:<line> -- set a breakpoint at a line clear <class id>.<method>[(argument_type,...)] -- clear a breakpoint in a method clear <class id>:<line> -- clear a breakpoint at a line clear -- list breakpoints catch [uncaught|caught|all] <class id>|<class pattern> -- break when specified exception occurs ignore [uncaught|caught|all] <class id>|<class pattern> -- cancel 'catch' for the specified exception watch [access|all] <class id>.<field name> -- watch access/modifications to a field unwatch [access|all] <class id>.<field name> -- discontinue watching access/modifications to a field trace methods [thread] -- trace method entry and exit untrace methods [thread] -- stop tracing method entry and exit step -- execute current line step up -- execute until the current method returns to its caller stepi -- execute current instruction next -- step one line (step OVER calls) cont -- continue execution from breakpoint 79
  • 88. ... list [line number|method] -- print source code use (or sourcepath) [source file path] -- display or change the source path exclude [<class pattern>, ... | "none"] -- do not report step or method events for specified classes classpath -- print classpath info from target VM monitor <command> -- execute command each time the program stops monitor -- list monitors unmonitor <monitor#> -- delete a monitor read <filename> -- read and execute a command file lock <expr> -- print lock info for an object threadlocks [thread id] -- print lock info for a thread pop -- pop the stack through and including the current frame reenter -- same as pop, but current frame is reentered redefine <class id> <class file name> -- redefine the code for a class disablegc <expr> -- prevent garbage collection of an object enablegc <expr> -- permit garbage collection of an object 80
  • 89. > threads Group system: (java.lang.ref.Reference$ReferenceHandler)0x41 Reference Handler unknown (java.lang.ref.Finalizer$FinalizerThread)0x40 Finalizer unknown (java.lang.Thread)0x3f Signal Dispatcher running (java.lang.Thread)0x3a RMI TCP Accept-1098 running (java.lang.Thread)0x38 RMI Reaper unknown (sun.misc.GC$Daemon)0x37 GC Daemon unknown (java.lang.Thread)0x34 RMI TCP Accept-1090 running (java.lang.Thread)0x33 RMI TCP Accept-0 running (java.lang.Thread)0x32 RMI RenewClean-[127.0.0.1:50475] unknown (java.lang.Thread)0x31 RMI LeaseChecker sleeping (java.lang.Thread)0x22 RMI TCP Accept-4444 running Group main: (java.lang.Thread)0x3e DestroyJavaVM running (java.lang.Thread)0x3 AWT-AppKit running Group jboss: (java.util.TimerThread)0x3d Timer-0 unknown (java.util.TimerThread)0x3c Timer-Log4jService unknown ... 81
  • 91. Divirta-se com todas as ferramentas apresentadas. Quem instanciou o objeto X? Quem está referenciando o objeto X? Quantas threads ficam bloqueadas durante os testes? Qual o pico de alocação da PermGen? Quais libs estão no classpath do classloader da aplicação? Qual a frequência de execução do GC na Young Gen? E na Old Gen? 83
  • 92. P&R

Editor's Notes

  1. Mem&amp;#xF3;ria dividida em duas grandes &amp;#xE1;reas.
  2. Mem&amp;#xF3;ria dividida em duas grandes &amp;#xE1;reas.
  3. Old Generation divida
  4. Old Generation divida
  5. Old Generation divida
  6. A Young Gen &amp;#xE9; ent&amp;#xE3;o divida em 3 partes.
  7. Objetos s&amp;#xE3;o imediatamente alocados no Eden Space. Busca-se manter o Eden sempre vazio, para que a aloca&amp;#xE7;&amp;#xE3;o seja a mais r&amp;#xE1;pida poss&amp;#xED;vel.
  8. Objetos s&amp;#xE3;o imediatamente alocados no Eden Space. Busca-se manter o Eden sempre vazio, para que a aloca&amp;#xE7;&amp;#xE3;o seja a mais r&amp;#xE1;pida poss&amp;#xED;vel.
  9. Como na Old Gen a frequ&amp;#xEA;ncia de coleta &amp;#xE9; bem menor, o impacto da compacta&amp;#xE7;&amp;#xE3;o n&amp;#xE3;o &amp;#xE9; t&amp;#xE3;o grande.