SlideShare a Scribd company logo
1 of 5
TROUBLESHOOTING HUNG/CRASHED PROCESSES

JSTACK – Stack tracing tool
jstack The jstack command-line utility attaches to the specified process or core file and prints the stack
traces of all threads that are attached to the virtual machine, including Java threads and VM internal
threads, and optionally native stack frames. The utility also performs deadlock detection. The utility can
also use the jsadebugd daemon to query a process or core file on a remote machine

Forcing a Stack Dump
If the jstack pid command does not respond because of a hung process, the -F option can be used (on
Solaris OS and Linux only) to force a stack dump, as in the following example:

$ jstack -F 8321

Printing Stack Trace From Core Dump
To obtain stack traces from a core dump (core.pid), execute the following command:

$ jstack $JAVA_HOME/bin/java core.pid


JSDEBUGD – Remote Debugging Server
jsadebugd attaches to a Java process or core file and acts as a debug server. Remote clients such as
jstack, jmap, and jinfo can attach to the server using Java Remote Method Invocation (RMI). Before
starting jsadebugd, rmiregistry must be started with:

$ rmiregistry -J-Xbootclasspath/p:$JAVA_HOME/lib/sajdi.jar

$ jsadebugd $JAVA_HOME/bin/java core.20441

Where $JAVA_HOME is the JDK installation directory. If rmiregistry was not started, jsadebugd will start
an rmiregistry in a standard (1099) port internally. Debug server may be stopped by sending SIGINT
(pressing Ctrl-C) to it.


JDB – Java Debugger
Using jdb to Attach to a Core File or Hung Process
The Java Debug Interface (JDI) is a high level Java API providing information useful for debuggers and
similar systems needing access to the running state of a (usually remote) virtual machine. JDI is a
component of the Java Platform Debugger Architecture (JPDA). In JDI a Connector is the means by which
the debugger connects to the target virtual machine. The JDK has traditionally shipped with Connectors
that launch and establish a debugging session with a target VM and also Connectors that are used for
remote debugging (using TCP/IP or shared memory transports).
JDK5.0 ships with three new Connectors on Solaris and Linux. These Connectors allow a Java Language
debugger (such as the sample jdb command-line debugger) to attach to a crash dump or hung process.
This can be useful when trying to diagnose what the application was doing at the time of the crash or
hang. The three Connectors are:

Connector Description
SA Core Attaching Connector: This Connector can be used by a debugger to debug a core file.

SA PID Attaching Connector: This Connector can be used by a debugger to debug a process.

SA Debug Server Attaching Connector This Connector can be used by a debugger to debug a process or
core file on a machine other than the machine upon which the debugger is running.

Further details about JPDA can be found at:
http://java.sun.com/j2se/1.5.0/docs/guide/jpda/index.html
http://java.sun.com/j2se/1.5.0/docs/guide/jpda/conninv.html

The following demonstrates usage of these Connectors with the jdb command-line debugger that ships
with JDK5.0. Generally, these Connectors will be used with more capable and enterprise debuggers
(such as as NetBeans IDE or commerical IDEs).

Attaching to a Process
In this example we use the “SA PID Attaching Connector” to attach to a process. The target process is
not started with any special options (-agentlib:jdwp option not required). When this Connector attaches
to a process it does so in read-only mode; that is the debugger can examine threads and the running
application but it cannot change anything. The command we use is as follows:

$ jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=20441

Initializing jdb...
> threads
          Group system:
          (java.lang.ref.Reference$ReferenceHandler)0x23 Reference Handler
          (java.lang.Thread)0x21 Signal Dispatcher running
          (java.lang.Thread)0x24 main running
[... more lines removed here to reduce output ...]


In this example the threads command is used to get a list of all threads. The process can be debugged to
any level. Notably, some very useful commands are “where al”l or “where <thread-id>” that gives us a
stack dump of all threads or a particular thread.

Attaching to a Core File
The SA Core Attaching Connector is used to attach the debugger to a core file. The core file may have
been created after a crash (see section 2.2), or obtained by using the gcore command on Solaris (or
gdb's gcore command on Linux). As the core file is a snapshot of the process at the time the core file was
created, the Connector attaches in read-only mode; that is the debugger can examine threads and the
running application at the time of the crash. Following is an example of using this Connector:

$ jdb -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector:
javaExecutable=$JAVA_HOME/bin/java,core=core.20441

This command instructs jdb to use a Connector named sun.jvm.hotspot.jdi.SACoreAttachingConnector.
The Connector takes two arguments called javaExecutable and core. The javaExecutable argument
indicates the name of the java binary. In this case the JAVA_HOME environment variable indicates the
JDK home directory. The core argument is the core file name (the core from process with pid 20441 in
this example).

To debug a core file that has been transported from another machine requires that the OS versions and
libraries match. Sometimes this can be difficult to organize. For those environments you can run a proxy
server called the SA Debug Server. Then, on the machine where the debugger is installed, you can use
the SA Debug Server Attaching Connector to connect to the debug server.

To demonstrate this, assume that we have machine 1 and machine 2. A core file is available on machine
1 and the debugger is available on machine 2. On machine 1 we start the SA Debug Server:

jsadebugd $JAVA_HOME/bin/java core.20441

jsadebugd takes two arguments here. The first is the name of the binary/executable. In most cases this
is java but it may be another name (in the case of embedded VMs for example). The second argument is
the name of the core file. In this example the core file was obtained for a process with pid 20441 using
the gcore utility.

On machine 2, we use the debugger to connect to the remote SA Debug Server using the SA Debug

Server Attaching Connector: Following is an example command:

jdb -connect sun.jvm.hotspot.jdi.SADebugServerAttachingConnector:
debugServerName=machine1

This      command         instructs      jdb     to      use     a      Connector       named
sun.jvm.hotspot.jdi.SADebugServerAttachingConnector. The Connector has a single argument
debugServerName which is the hostname or IP address of the machine where the SA Debug Server is
running.

Note that the SA Debug Server can also be used to remotely debug a hung process. In that case it takes a
single argument which is the process-id of the process. Also, if it is required to run multiple debug
servers on the same machine then each one must be provided with a unique ID. When using the SA
Debug Server Attaching Connector this ID is provided as an additional Connector argument. These
details are described in the JPDA documentation.
JMAP and JHAT


Histograms
You can try to quickly narrow down a memory leak by examining a heap histogram. This information can
be obtained in several ways:

 A heap histogram can be obtained from a running process using the command jmap –histo pid. The
output shows the total size and instance count for each class type in the heap. If a sequence of
histograms is obtained (for example, every 2 minutes), then you might be able to observe a trend that
can lead to further analysis.

On Solaris OS and Linux, the jmap utility can also provide a histogram from a core file. If the Java
process is started with the -XX:+PrintClassHistogram command-line option, then the Ctrl-Break or kill -3
<pid> handler will produce a heap histogram.

If you specify the -XX:+HeapDumpOnOutOfMemoryError command-line option, and if an
OutOfMemoryError is thrown, the VM generates a heap dump. You can then use the jmap utility to
obtain a histogram from the heap dump.

If a core file is produced when the OutOfMemoryError is thrown, you can execute jmap on the core file
to get a histogram, as in the following example.

$ jmap -histo latest/binaries/solaris-sparc/bin/java core.27421

        Attaching to core core.27421 from executable
        latest/binaries/solaris-sparc/bin/java, please wait...
        Debugger attached successfully.
        Server compiler detected.
        JVM version is 1.6.0-beta-b63
        Iterating over heap. This may take a while...
        Heap traversal took 8.902 seconds.
        Object Histogram:
        Size                 Count Class description
        -------------------------------------------------------
        86683872             3611828 java.lang.String
        9136                 204          java.lang.Object[]
        136                  104          com.redknee.xhome.Context
.....

The size information doesn’t reflect the containment. For example; if all these Strings were a part of
Context instances; the size of the Context instances would not sum up the size of encapsulated Strings
but will just count the size of references and basic types.

The example shows that the OutOfMemoryError is caused by the number of java.lang.String objects
(3611828 instances in the heap). Without further analysis it is not clear where the strings are allocated.
However, the information is still useful and the investigation can continue with tools such as jhat to find
out where the strings are allocated, as well as what references are keeping them alive and preventing
them from being garbage collected.

Heap Anakysis
The jhat tool provides a convenient means to browse the object topology in a heap snapshot. This tool
was introduced in the Java SE 6 release to replace theHeap Analysis Tool (HAT). For more information
about the jhat utility, see the man page for jhat- JavaHeap Analysis Tool
(http://java.sun.com/javase/6/docs/technotes/tools/share/jhat.html).

The tool parses a heap dump in binary format, for example, a heap dump produced by jmap -dump.
Class histogram è jmap –histo <pid>
Heap-dump         è (Take only when the load is low)
 If the application is on java1.5, the following command will produce heap dump for process with given
<pid> in heap.bin
jmap -dump:format=b,file=heap.bin <pid>

If the application is on java1.6, it is little different and we also have a live heap dump option.
 $ /usr/java1.6/bin/jmap -dump:live,format=b,file=heap.live.bin 17390
$ /usr/java1.6/bin/jmap -dump:format=b,file=heap.bin 17390
The each of the two commands produce heap dumps in the corresponding mentioned files
(heap.live.bin and heab.bin). Live heap dump will only include the objects which are live in the heap.

The following example shows how to execute jhat to analyze a heap dump file named snapshot.hprof:
$ jhat snapshot.hprof

         Started HTTP server on port 7000
         Reading from java_pid2278.hprof...
         Dump file created Fri May 19 17:18:38 BST 2006
         Snapshot read, resolving...
         Resolving 6162194 objects...
         Chasing references, expect 12324 dots................................
         Eliminating duplicate references.....................................
         Snapshot resolved.
         Server is ready.
At this point jhat has started a HTTP server on port 7000. Point your browser to
http://localhost:7000  to connect to the jhat server.
                                                Heap Histogram
                                      All Classes (excluding platform)
               Class                                            Instance Count Total Size
               class [C                                         1783391         134258772
               class [Ljava.util.HashMap$Entry;                 874568          63286080
               class com.redknee.framework.xlog.om.PMLog 868701                 57334266
The size information doesn’t reflect the size of contained object(s). It just sums up the referency type
size for contained Object(s) plus the size of basic type attributes.

More Related Content

Recently uploaded

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

Featured

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Featured (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Hung or crashed process final

  • 1. TROUBLESHOOTING HUNG/CRASHED PROCESSES JSTACK – Stack tracing tool jstack The jstack command-line utility attaches to the specified process or core file and prints the stack traces of all threads that are attached to the virtual machine, including Java threads and VM internal threads, and optionally native stack frames. The utility also performs deadlock detection. The utility can also use the jsadebugd daemon to query a process or core file on a remote machine Forcing a Stack Dump If the jstack pid command does not respond because of a hung process, the -F option can be used (on Solaris OS and Linux only) to force a stack dump, as in the following example: $ jstack -F 8321 Printing Stack Trace From Core Dump To obtain stack traces from a core dump (core.pid), execute the following command: $ jstack $JAVA_HOME/bin/java core.pid JSDEBUGD – Remote Debugging Server jsadebugd attaches to a Java process or core file and acts as a debug server. Remote clients such as jstack, jmap, and jinfo can attach to the server using Java Remote Method Invocation (RMI). Before starting jsadebugd, rmiregistry must be started with: $ rmiregistry -J-Xbootclasspath/p:$JAVA_HOME/lib/sajdi.jar $ jsadebugd $JAVA_HOME/bin/java core.20441 Where $JAVA_HOME is the JDK installation directory. If rmiregistry was not started, jsadebugd will start an rmiregistry in a standard (1099) port internally. Debug server may be stopped by sending SIGINT (pressing Ctrl-C) to it. JDB – Java Debugger Using jdb to Attach to a Core File or Hung Process The Java Debug Interface (JDI) is a high level Java API providing information useful for debuggers and similar systems needing access to the running state of a (usually remote) virtual machine. JDI is a component of the Java Platform Debugger Architecture (JPDA). In JDI a Connector is the means by which the debugger connects to the target virtual machine. The JDK has traditionally shipped with Connectors that launch and establish a debugging session with a target VM and also Connectors that are used for remote debugging (using TCP/IP or shared memory transports).
  • 2. JDK5.0 ships with three new Connectors on Solaris and Linux. These Connectors allow a Java Language debugger (such as the sample jdb command-line debugger) to attach to a crash dump or hung process. This can be useful when trying to diagnose what the application was doing at the time of the crash or hang. The three Connectors are: Connector Description SA Core Attaching Connector: This Connector can be used by a debugger to debug a core file. SA PID Attaching Connector: This Connector can be used by a debugger to debug a process. SA Debug Server Attaching Connector This Connector can be used by a debugger to debug a process or core file on a machine other than the machine upon which the debugger is running. Further details about JPDA can be found at: http://java.sun.com/j2se/1.5.0/docs/guide/jpda/index.html http://java.sun.com/j2se/1.5.0/docs/guide/jpda/conninv.html The following demonstrates usage of these Connectors with the jdb command-line debugger that ships with JDK5.0. Generally, these Connectors will be used with more capable and enterprise debuggers (such as as NetBeans IDE or commerical IDEs). Attaching to a Process In this example we use the “SA PID Attaching Connector” to attach to a process. The target process is not started with any special options (-agentlib:jdwp option not required). When this Connector attaches to a process it does so in read-only mode; that is the debugger can examine threads and the running application but it cannot change anything. The command we use is as follows: $ jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=20441 Initializing jdb... > threads Group system: (java.lang.ref.Reference$ReferenceHandler)0x23 Reference Handler (java.lang.Thread)0x21 Signal Dispatcher running (java.lang.Thread)0x24 main running [... more lines removed here to reduce output ...] In this example the threads command is used to get a list of all threads. The process can be debugged to any level. Notably, some very useful commands are “where al”l or “where <thread-id>” that gives us a stack dump of all threads or a particular thread. Attaching to a Core File The SA Core Attaching Connector is used to attach the debugger to a core file. The core file may have been created after a crash (see section 2.2), or obtained by using the gcore command on Solaris (or gdb's gcore command on Linux). As the core file is a snapshot of the process at the time the core file was
  • 3. created, the Connector attaches in read-only mode; that is the debugger can examine threads and the running application at the time of the crash. Following is an example of using this Connector: $ jdb -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector: javaExecutable=$JAVA_HOME/bin/java,core=core.20441 This command instructs jdb to use a Connector named sun.jvm.hotspot.jdi.SACoreAttachingConnector. The Connector takes two arguments called javaExecutable and core. The javaExecutable argument indicates the name of the java binary. In this case the JAVA_HOME environment variable indicates the JDK home directory. The core argument is the core file name (the core from process with pid 20441 in this example). To debug a core file that has been transported from another machine requires that the OS versions and libraries match. Sometimes this can be difficult to organize. For those environments you can run a proxy server called the SA Debug Server. Then, on the machine where the debugger is installed, you can use the SA Debug Server Attaching Connector to connect to the debug server. To demonstrate this, assume that we have machine 1 and machine 2. A core file is available on machine 1 and the debugger is available on machine 2. On machine 1 we start the SA Debug Server: jsadebugd $JAVA_HOME/bin/java core.20441 jsadebugd takes two arguments here. The first is the name of the binary/executable. In most cases this is java but it may be another name (in the case of embedded VMs for example). The second argument is the name of the core file. In this example the core file was obtained for a process with pid 20441 using the gcore utility. On machine 2, we use the debugger to connect to the remote SA Debug Server using the SA Debug Server Attaching Connector: Following is an example command: jdb -connect sun.jvm.hotspot.jdi.SADebugServerAttachingConnector: debugServerName=machine1 This command instructs jdb to use a Connector named sun.jvm.hotspot.jdi.SADebugServerAttachingConnector. The Connector has a single argument debugServerName which is the hostname or IP address of the machine where the SA Debug Server is running. Note that the SA Debug Server can also be used to remotely debug a hung process. In that case it takes a single argument which is the process-id of the process. Also, if it is required to run multiple debug servers on the same machine then each one must be provided with a unique ID. When using the SA Debug Server Attaching Connector this ID is provided as an additional Connector argument. These details are described in the JPDA documentation.
  • 4. JMAP and JHAT Histograms You can try to quickly narrow down a memory leak by examining a heap histogram. This information can be obtained in several ways: A heap histogram can be obtained from a running process using the command jmap –histo pid. The output shows the total size and instance count for each class type in the heap. If a sequence of histograms is obtained (for example, every 2 minutes), then you might be able to observe a trend that can lead to further analysis. On Solaris OS and Linux, the jmap utility can also provide a histogram from a core file. If the Java process is started with the -XX:+PrintClassHistogram command-line option, then the Ctrl-Break or kill -3 <pid> handler will produce a heap histogram. If you specify the -XX:+HeapDumpOnOutOfMemoryError command-line option, and if an OutOfMemoryError is thrown, the VM generates a heap dump. You can then use the jmap utility to obtain a histogram from the heap dump. If a core file is produced when the OutOfMemoryError is thrown, you can execute jmap on the core file to get a histogram, as in the following example. $ jmap -histo latest/binaries/solaris-sparc/bin/java core.27421 Attaching to core core.27421 from executable latest/binaries/solaris-sparc/bin/java, please wait... Debugger attached successfully. Server compiler detected. JVM version is 1.6.0-beta-b63 Iterating over heap. This may take a while... Heap traversal took 8.902 seconds. Object Histogram: Size Count Class description ------------------------------------------------------- 86683872 3611828 java.lang.String 9136 204 java.lang.Object[] 136 104 com.redknee.xhome.Context ..... The size information doesn’t reflect the containment. For example; if all these Strings were a part of Context instances; the size of the Context instances would not sum up the size of encapsulated Strings but will just count the size of references and basic types. The example shows that the OutOfMemoryError is caused by the number of java.lang.String objects (3611828 instances in the heap). Without further analysis it is not clear where the strings are allocated.
  • 5. However, the information is still useful and the investigation can continue with tools such as jhat to find out where the strings are allocated, as well as what references are keeping them alive and preventing them from being garbage collected. Heap Anakysis The jhat tool provides a convenient means to browse the object topology in a heap snapshot. This tool was introduced in the Java SE 6 release to replace theHeap Analysis Tool (HAT). For more information about the jhat utility, see the man page for jhat- JavaHeap Analysis Tool (http://java.sun.com/javase/6/docs/technotes/tools/share/jhat.html). The tool parses a heap dump in binary format, for example, a heap dump produced by jmap -dump. Class histogram è jmap –histo <pid> Heap-dump è (Take only when the load is low) If the application is on java1.5, the following command will produce heap dump for process with given <pid> in heap.bin jmap -dump:format=b,file=heap.bin <pid> If the application is on java1.6, it is little different and we also have a live heap dump option. $ /usr/java1.6/bin/jmap -dump:live,format=b,file=heap.live.bin 17390 $ /usr/java1.6/bin/jmap -dump:format=b,file=heap.bin 17390 The each of the two commands produce heap dumps in the corresponding mentioned files (heap.live.bin and heab.bin). Live heap dump will only include the objects which are live in the heap. The following example shows how to execute jhat to analyze a heap dump file named snapshot.hprof: $ jhat snapshot.hprof Started HTTP server on port 7000 Reading from java_pid2278.hprof... Dump file created Fri May 19 17:18:38 BST 2006 Snapshot read, resolving... Resolving 6162194 objects... Chasing references, expect 12324 dots................................ Eliminating duplicate references..................................... Snapshot resolved. Server is ready. At this point jhat has started a HTTP server on port 7000. Point your browser to http://localhost:7000  to connect to the jhat server. Heap Histogram All Classes (excluding platform) Class Instance Count Total Size class [C 1783391 134258772 class [Ljava.util.HashMap$Entry; 874568 63286080 class com.redknee.framework.xlog.om.PMLog 868701 57334266 The size information doesn’t reflect the size of contained object(s). It just sums up the referency type size for contained Object(s) plus the size of basic type attributes.