SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
Debugging Your
Production JVM Machine
Ken Sipe
Perficient (PRFT)
kensipe@gmail.com
Abstract
> Learn the tools and techniques used to monitor,
trace and debugging running Java applications.
2
Agenda
> Java Memory Management
> Memory Management Tools
• Command-line Tools
• VisualVM
> Btrace
> Summary
> Resources
3
Agenda
> Java Memory Management
> Memory Management Tools
• Command-line Tools
• VisualVM
> Btrace
> Summary
> Resources
4
Donʼt Worry…
> C (malloc / free)
> C++ (new / delete)
> Java (new / gc)
> Memory Allocation / Deallocation in Java is
automatic
5
Object Lifetimes
> Most objects live very short lives
• 80-98% of all newly allocated objects die
• within a few million instructions
• Before another megabyte is allocated
> Old objects tend to live a long…. time
Memory Spaces
> New Space
• Where all objects are new (sort of…)
> Old Space
• Where all objects are old
New Space Old Space
Memory Spaces
> New Space Division
• Eden
• Where all objects are created
• Survivor Space 0
• Provide object aging
• Survivor Space 1
Eden Old SpaceSS0 SS1
Perm Spaces
> Permanent Space
• class information
• static information
Eden Old SpaceSS0 SS1 Perm Space
GC Responsibility
> Heap Walking from GC Roots
> Mark / Sweep
• Garbage detection (mark)
• Sort out the live ones from the dead ones
• Reference counting
• Garbage reclamation (sweep)
• Make space available
Minor Garbage Collection
> Minor gc (scavenge)
• When eden is “full” a minor gc is invoked
• Sweeps through eden and the current survivor
space, removing the dead and moving the living to
survivor space or old
• Ss0 and ss1 switch which is “current”
• A new tenuring age is calculated
Major Garbage Collection
> Major gc
• When old is “full”
• All spaces are garbage collected including perm
space
• All other activities in the jvm are suspended
Agenda
> Java Memory Management
> Memory Management Tools
• Command-line Tools
• VisualVM
> Btrace
> Summary
> Resources
14
Java Memory Tools
> JPS
• Getting the Process ID (PID)
> Jstat
• jstat -gcutil <pid> 250 7
Looking at the Heap
> %JAVA_HOME%/bin/jmap – histo:live <pid>
• Looking at all the “live” objects
> %JAVA_HOME%/bin/jmap – histo <pid>
• Looking at all objects
> The difference between is the list of unreachable
objects
Taking a Heap Dump
> %JAVA_HOME%/bin/jmap –
dump:live,file=heap.out,format=b <pid>
• Dumps the Heap to a file
> JConsole
JHat
> %JAVA_HOME%/bin/jhat <filename>
• Starts a web server to investigate the heap
> Queries
• Show instance count for all classes
• Show Heap Histogram
• Show Finalizer
• Use the Execute Object Query Language (OQL)
• select s from java.lang.String s where s.count >=100
JMX – Looking at Flags
MAT – Memory Analyzer Tool
VisualVM
> Open Source All-in-One Java Troubleshooting tool
> https://visualvm.dev.java.net/
21
Visualgc
> visualgc <pid>
> Visual Garbage Collection
Monitoring
• a graphical tool for monitoring the
HotSpot Garbage Collector,
Compiler, and class loader. It can
monitor both local and remote
JVMs.
23
DEMO
Agenda
> Java Memory Management
> Memory Management Tools
• Command-line Tools
• VisualVM
> Btrace
> Summary
> Resources
24
BTrace
> dynamically bytecode instrumenting (BCI)
• read / not write
• probe-based
• observe running Java applications
> Integration with DTrace on Solaris
> http://btrace.dev.java.net
> visualvm plugin
25
BTrace Tools
26
Target JVM
BTrace
Agent
VisualVM +
BTrace Plugin
BTrace command-line
BTrace Terminology
> Probe Point
• “location” or “event” at which tracing statements are
executed
> Trace Actions
• statements which are executed whenever a probe
fires
> Action Methods
• static methods which define a trace
27
Probes and Actions
> Probe Targets
• method entry / exit
• line number
• exceptions
• return from method
• exception throw (before)
• synchronization entry / exit
> Actions
• static methods in trace class
28
BTrace Restrictions
> no new objects
> no new arrays
> no exceptions
> no outer, inner, nested or
local classes
> no synchronization blocks
> no loops
> no interfaces
29
Tracing
> Annotations
• com.sun.btrace.annotations
• @BTrace
• denotes a btrace class
> Probe Points
• @OnMethod
• @OnTimer
• @OnEvent
• @OnExit
30
Simple Example: Looking for Object Size
31
Simple Example: Looking for Object Size
32
BTrace Run Options
> BTrace Command-Line
• btrace
• runs btrace tool (and compiles btrace script if necessary)
• btracec
• btrace script compiler
• btracer
• convenience script to start java project with tracing enabled at
application startup
> VisualVM + BTrace Plugin
33
Testing the Probe
> Start Target Application
• java -jar java2demo.jar
> Get the PID
• jps
> Inject Probe
• btrace <pid> Sizeof.java
34
BTrace + JMX Script
35
BTrace + jstat
36
ThreadLocal
37
BTrace Events
38
Checking Synchronization Entry / Exits
39
Tracing Opportunities
> Thread Monitors
> Socket / Web Services
> Object Creation and Size
> File Access
40
41
DEMO
Known Solutions with BTrace
> Terracotta
• concurrency issue
> Hibernate / Atlassian Issue
• thread / session management issue
• http://jira.atlassian.com/browse/CONF-12201
42
Summary
> jmap, jhat, jconsole, jstat
• tools already in the JDK bin directory
> VisualVM
• swiss army knife for JVM process monitoring and
tracing
> BTrace
• dynamic tracing tool
43
Resources
> Performance and Troubleshooting
• http://java.sun.com/performance/reference/
whitepapers/6_performance.html
• http://java.sun.com/javase/6/webnotes/trouble/TSG-
VM/html/docinfo.html
> VisualVM
• https://visualvm.dev.java.net/
> BTrace
• https://btrace.dev.java.net/
44
Ken Sipe
http://kensipe.blogspot.com
twitter: @kensipe

Weitere ähnliche Inhalte

Was ist angesagt?

Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure java
Roman Elizarov
 
RedisConf17 - Internet Archive - Preventing Cache Stampede with Redis and XFetch
RedisConf17 - Internet Archive - Preventing Cache Stampede with Redis and XFetchRedisConf17 - Internet Archive - Preventing Cache Stampede with Redis and XFetch
RedisConf17 - Internet Archive - Preventing Cache Stampede with Redis and XFetch
Redis Labs
 
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugVk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
ketan_patel25
 

Was ist angesagt? (20)

Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage Collection
 
Performance and predictability
Performance and predictabilityPerformance and predictability
Performance and predictability
 
Java collections the force awakens
Java collections  the force awakensJava collections  the force awakens
Java collections the force awakens
 
JCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of JavaJCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of Java
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
 
Finalize() method
Finalize() methodFinalize() method
Finalize() method
 
cb streams - gavin pickin
cb streams - gavin pickincb streams - gavin pickin
cb streams - gavin pickin
 
Stream processing from single node to a cluster
Stream processing from single node to a clusterStream processing from single node to a cluster
Stream processing from single node to a cluster
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure java
 
Understanding Garbage Collection
Understanding Garbage CollectionUnderstanding Garbage Collection
Understanding Garbage Collection
 
Garbage collection in JVM
Garbage collection in JVMGarbage collection in JVM
Garbage collection in JVM
 
BDM32: AdamCloud Project - Part II
BDM32: AdamCloud Project - Part IIBDM32: AdamCloud Project - Part II
BDM32: AdamCloud Project - Part II
 
(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag Session(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag Session
 
Performance van Java 8 en verder - Jeroen Borgers
Performance van Java 8 en verder - Jeroen BorgersPerformance van Java 8 en verder - Jeroen Borgers
Performance van Java 8 en verder - Jeroen Borgers
 
Dive into spark2
Dive into spark2Dive into spark2
Dive into spark2
 
Java GC
Java GCJava GC
Java GC
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
 
RedisConf17 - Internet Archive - Preventing Cache Stampede with Redis and XFetch
RedisConf17 - Internet Archive - Preventing Cache Stampede with Redis and XFetchRedisConf17 - Internet Archive - Preventing Cache Stampede with Redis and XFetch
RedisConf17 - Internet Archive - Preventing Cache Stampede with Redis and XFetch
 
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugVk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
 

Ähnlich wie Debugging Your Production JVM

java-monitoring-troubleshooting
java-monitoring-troubleshootingjava-monitoring-troubleshooting
java-monitoring-troubleshooting
William Au
 
Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0
Jarod Wang
 
One-Byte Modification for Breaking Memory Forensic Analysis
One-Byte Modification for Breaking Memory Forensic AnalysisOne-Byte Modification for Breaking Memory Forensic Analysis
One-Byte Modification for Breaking Memory Forensic Analysis
Takahiro Haruyama
 
mobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptxmobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptx
NgLQun
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Lucidworks
 

Ähnlich wie Debugging Your Production JVM (20)

java-monitoring-troubleshooting
java-monitoring-troubleshootingjava-monitoring-troubleshooting
java-monitoring-troubleshooting
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
 
12 virtualmachine
12 virtualmachine12 virtualmachine
12 virtualmachine
 
Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0
 
Unit iii pds
Unit iii pdsUnit iii pds
Unit iii pds
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
One-Byte Modification for Breaking Memory Forensic Analysis
One-Byte Modification for Breaking Memory Forensic AnalysisOne-Byte Modification for Breaking Memory Forensic Analysis
One-Byte Modification for Breaking Memory Forensic Analysis
 
.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuning
 
Micrometrics to forecast performance tsunamis
Micrometrics to forecast performance tsunamisMicrometrics to forecast performance tsunamis
Micrometrics to forecast performance tsunamis
 
Solaris DTrace, An Introduction
Solaris DTrace, An IntroductionSolaris DTrace, An Introduction
Solaris DTrace, An Introduction
 
Day 7 - Make it Fast
Day 7 - Make it FastDay 7 - Make it Fast
Day 7 - Make it Fast
 
mobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptxmobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptx
 
JDK Tools For Performance Diagnostics
JDK Tools For Performance DiagnosticsJDK Tools For Performance Diagnostics
JDK Tools For Performance Diagnostics
 
Building source code level profiler for C++.pdf
Building source code level profiler for C++.pdfBuilding source code level profiler for C++.pdf
Building source code level profiler for C++.pdf
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Debugging Your Production JVM

  • 1. Debugging Your Production JVM Machine Ken Sipe Perficient (PRFT) kensipe@gmail.com
  • 2. Abstract > Learn the tools and techniques used to monitor, trace and debugging running Java applications. 2
  • 3. Agenda > Java Memory Management > Memory Management Tools • Command-line Tools • VisualVM > Btrace > Summary > Resources 3
  • 4. Agenda > Java Memory Management > Memory Management Tools • Command-line Tools • VisualVM > Btrace > Summary > Resources 4
  • 5. Donʼt Worry… > C (malloc / free) > C++ (new / delete) > Java (new / gc) > Memory Allocation / Deallocation in Java is automatic 5
  • 6. Object Lifetimes > Most objects live very short lives • 80-98% of all newly allocated objects die • within a few million instructions • Before another megabyte is allocated > Old objects tend to live a long…. time
  • 7. Memory Spaces > New Space • Where all objects are new (sort of…) > Old Space • Where all objects are old New Space Old Space
  • 8. Memory Spaces > New Space Division • Eden • Where all objects are created • Survivor Space 0 • Provide object aging • Survivor Space 1 Eden Old SpaceSS0 SS1
  • 9. Perm Spaces > Permanent Space • class information • static information Eden Old SpaceSS0 SS1 Perm Space
  • 10. GC Responsibility > Heap Walking from GC Roots > Mark / Sweep • Garbage detection (mark) • Sort out the live ones from the dead ones • Reference counting • Garbage reclamation (sweep) • Make space available
  • 11. Minor Garbage Collection > Minor gc (scavenge) • When eden is “full” a minor gc is invoked • Sweeps through eden and the current survivor space, removing the dead and moving the living to survivor space or old • Ss0 and ss1 switch which is “current” • A new tenuring age is calculated
  • 12. Major Garbage Collection > Major gc • When old is “full” • All spaces are garbage collected including perm space • All other activities in the jvm are suspended
  • 13.
  • 14. Agenda > Java Memory Management > Memory Management Tools • Command-line Tools • VisualVM > Btrace > Summary > Resources 14
  • 15. Java Memory Tools > JPS • Getting the Process ID (PID) > Jstat • jstat -gcutil <pid> 250 7
  • 16. Looking at the Heap > %JAVA_HOME%/bin/jmap – histo:live <pid> • Looking at all the “live” objects > %JAVA_HOME%/bin/jmap – histo <pid> • Looking at all objects > The difference between is the list of unreachable objects
  • 17. Taking a Heap Dump > %JAVA_HOME%/bin/jmap – dump:live,file=heap.out,format=b <pid> • Dumps the Heap to a file > JConsole
  • 18. JHat > %JAVA_HOME%/bin/jhat <filename> • Starts a web server to investigate the heap > Queries • Show instance count for all classes • Show Heap Histogram • Show Finalizer • Use the Execute Object Query Language (OQL) • select s from java.lang.String s where s.count >=100
  • 19. JMX – Looking at Flags
  • 20. MAT – Memory Analyzer Tool
  • 21. VisualVM > Open Source All-in-One Java Troubleshooting tool > https://visualvm.dev.java.net/ 21
  • 22. Visualgc > visualgc <pid> > Visual Garbage Collection Monitoring • a graphical tool for monitoring the HotSpot Garbage Collector, Compiler, and class loader. It can monitor both local and remote JVMs.
  • 24. Agenda > Java Memory Management > Memory Management Tools • Command-line Tools • VisualVM > Btrace > Summary > Resources 24
  • 25. BTrace > dynamically bytecode instrumenting (BCI) • read / not write • probe-based • observe running Java applications > Integration with DTrace on Solaris > http://btrace.dev.java.net > visualvm plugin 25
  • 26. BTrace Tools 26 Target JVM BTrace Agent VisualVM + BTrace Plugin BTrace command-line
  • 27. BTrace Terminology > Probe Point • “location” or “event” at which tracing statements are executed > Trace Actions • statements which are executed whenever a probe fires > Action Methods • static methods which define a trace 27
  • 28. Probes and Actions > Probe Targets • method entry / exit • line number • exceptions • return from method • exception throw (before) • synchronization entry / exit > Actions • static methods in trace class 28
  • 29. BTrace Restrictions > no new objects > no new arrays > no exceptions > no outer, inner, nested or local classes > no synchronization blocks > no loops > no interfaces 29
  • 30. Tracing > Annotations • com.sun.btrace.annotations • @BTrace • denotes a btrace class > Probe Points • @OnMethod • @OnTimer • @OnEvent • @OnExit 30
  • 31. Simple Example: Looking for Object Size 31
  • 32. Simple Example: Looking for Object Size 32
  • 33. BTrace Run Options > BTrace Command-Line • btrace • runs btrace tool (and compiles btrace script if necessary) • btracec • btrace script compiler • btracer • convenience script to start java project with tracing enabled at application startup > VisualVM + BTrace Plugin 33
  • 34. Testing the Probe > Start Target Application • java -jar java2demo.jar > Get the PID • jps > Inject Probe • btrace <pid> Sizeof.java 34
  • 35. BTrace + JMX Script 35
  • 40. Tracing Opportunities > Thread Monitors > Socket / Web Services > Object Creation and Size > File Access 40
  • 42. Known Solutions with BTrace > Terracotta • concurrency issue > Hibernate / Atlassian Issue • thread / session management issue • http://jira.atlassian.com/browse/CONF-12201 42
  • 43. Summary > jmap, jhat, jconsole, jstat • tools already in the JDK bin directory > VisualVM • swiss army knife for JVM process monitoring and tracing > BTrace • dynamic tracing tool 43
  • 44. Resources > Performance and Troubleshooting • http://java.sun.com/performance/reference/ whitepapers/6_performance.html • http://java.sun.com/javase/6/webnotes/trouble/TSG- VM/html/docinfo.html > VisualVM • https://visualvm.dev.java.net/ > BTrace • https://btrace.dev.java.net/ 44

Hinweis der Redaktion