Troubleshooting Guide
Total Page:16
File Type:pdf, Size:1020Kb
Java Platform, Standard Edition Troubleshooting Guide Release 13 F17440-01 September 2019 Java Platform, Standard Edition Troubleshooting Guide, Release 13 F17440-01 Copyright © 1995, 2019, Oracle and/or its affiliates. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency- specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government. This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle. Contents Preface Audience xi Documentation Accessibility xi Related Documents xi Conventions xi Part I General Java Troubleshooting 1 Prepare Java for Troubleshooting Set Up Java for Troubleshooting 1-1 Enable Options and Flags for JVM Troubleshooting 1-1 Gather Relevant Data 1-3 Make a Java Application Easier to Debug 1-3 2 Diagnostic Tools Diagnostic Tools Overview 2-1 Flight Recorder 2-2 About Flight Recordings 2-3 Produce a Flight Recording 2-4 Inspect a Flight Recording 2-5 The jcmd Utility 2-6 Useful Commands for the jcmd Utility 2-8 Troubleshoot with the jcmd Utility 2-9 Native Memory Tracking 2-9 Use NMT to Detect a Memory Leak 2-10 How to Monitor VM Internal Memory 2-10 NMT Memory Categories 2-15 JConsole 2-16 Troubleshoot with the JConsole Tool 2-16 Monitor Local and Remote Applications with JConsole 2-18 iii The jdb Utility 2-19 Troubleshoot with the jdb Utility 2-19 The jinfo Utility 2-20 Troubleshooting with the jinfo Utility 2-21 The jmap Utility 2-22 Heap Configuration and Usage 2-22 Heap Histogram 2-23 Class Loader Statistics 2-25 The jps Utility 2-27 The jrunscript Utility 2-27 The jstack Utility 2-27 Troubleshoot with the jstack Utility 2-28 Stack Trace from a Core Dump 2-28 Mixed Stack 2-28 The jstat Utility 2-30 The visualgc Tool 2-32 Control+Break Handler 2-33 Thread Dump 2-33 Thread States for a Thread Dump 2-34 Detect Deadlocks 2-35 Heap Summary 2-35 Native Operating System Tools 2-36 Troubleshooting Tools Based on the Operating System 2-36 Probe Providers in Java HotSpot VM 2-37 Custom Diagnostic Tools 2-38 The java.lang.management Package 2-39 The java.lang.instrument Package 2-39 The java.lang.Thread Class 2-39 JVM Tool Interface 2-40 Java Platform Debugger Architecture 2-40 Postmortem Diagnostic Tools 2-40 Hung Processes Tools 2-41 Monitoring Tools 2-42 Other Tools, Options, Variables, and Properties 2-43 The jstatd Daemon 2-44 3 Troubleshoot Memory Leaks Debug a Memory Leak Using Flight Recorder 3-1 Understand the OutOfMemoryError Exception 3-4 Troubleshoot a Crash Instead of OutOfMemoryError 3-7 iv Diagnose Leaks in Java Language Code 3-7 Get a Heap Histogram 3-8 Monitor the Objects Pending Finalization 3-9 Diagnose Leaks in Native Code 3-9 Track All Memory Allocation and Free Calls 3-10 Track All Memory Allocations in the JNI Library 3-10 Track Memory Allocation with Operating System Support 3-11 4 Troubleshoot Performance Issues Using Flight Recorder Flight Recorder Overhead 4-1 Find Bottlenecks 4-2 Garbage Collection Performance 4-3 Synchronization Performance 4-4 I/O Performance 4-5 Code Execution Performance 4-5 Part II Debug JVM Issues 5 Troubleshoot System Crashes Determine Where the Crash Occurred 5-1 Crash the Native Code 5-2 Crash in the Compiled Code 5-3 Crash in the HotSpot Compiler Thread 5-4 Crash in the VM Thread 5-4 Crash Due to Stack Overflow 5-4 Find a Workaround 5-6 Working Around Crashes in the HotSpot Compiler Thread or Compiled Code 5-6 Working Around Crashes During Garbage Collection 5-8 Working Around Crashes Caused by Class Data Sharing 5-10 Microsoft Visual C++ Version Considerations 5-10 6 Troubleshoot Process Hangs and Loops Diagnose a Loop Process 6-1 Diagnose a Hung Process 6-2 Deadlock Detected 6-2 Deadlock Not Detected 6-4 No Thread Dump 6-4 v 7 Handle Signals and Exceptions Handle Signals on Linux and macOS 7-1 Handle Exceptions on Windows 7-1 Signal Chaining 7-3 Handle Exceptions Using the Java HotSpot VM 7-5 Console Handlers 7-5 Signals Used in Linux and macOS 7-5 Part III Debug Core Library Issues 8 Time Zone Settings in the JRE Native Time Zone Information and the JRE 8-1 Determine the Time Zone Data Version in Use 8-2 Troubleshoot Problems with TZupdater 8-2 Determine the Default Time Zone on Windows 8-3 Check the Default Time Zone Java Runtime Reports 8-3 Determine the Setting in the Control Panel 8-4 Check for Automatic Daylight Saving Time Adjustment 8-4 Set the Default Time Zone in Windows Settings 8-5 Check -Duser.timezone System Property 8-5 Special Tool in Windows 8-5 Internal Representation of Time Zone Mappings 8-6 Part IV Debug Client Issues 9 Introduction to Client Issues Java SE Desktop Technologies 9-1 General Steps to Troubleshoot an Issue 9-3 Identify the Type of Issue 9-3 Java Client Crashes 9-4 Performance Problems 9-4 Behavior Problems 9-5 Basic Tools 9-6 Java Debug Wire Protocol 9-6 vi 10 AWT Debug Tips for AWT 10-1 Layout Manager Issues 10-2 Key Events 10-2 Modality Issues 10-3 AWT Crashes 10-3 Focus Events 10-5 How to Trace Focus Events 10-5 Native Focus System 10-6 Focus Models Supported by X Window Managers 10-7 Miscellaneous Problems with Focus 10-7 Data Transfer 10-9 Debug Drag-and-Drop Applications 10-9 Frequent Issues with Data Transfer 10-9 Other Issues 10-12 Splash Screen Issues 10-12 Tray Icon Issues 10-13 Pop-up Menu Issues 10-13 Background or Foreground Color Inheritance 10-13 AWT Panel Size Restriction 10-13 Hangs During Debugging of Pop-up Menus and Similar Components on X11 10-14 Window.toFront()/toBack() Behavior on X11 10-14 Heavyweight or Lightweight Components Mix 10-15 11 Java 2D Pipeline Rendering and Properties Linux: X11 Pipeline 11-1 X11 Pipeline Pixmaps Properties 11-2 X11 Pipeline MIT Shared Memory Extension 11-3 Windows OS - DirectDraw/GDI Pipeline 11-3 Windows OS - Direct3D Pipeline in Full-Screen Mode 11-5 OpenGL Pipeline in Linux and Windows 11-6 Enable OpenGL Pipeline 11-6 Minimum Requirements 11-6 Diagnose Startup Issues 11-7 Diagnose Rendering and Performance Issues 11-7 Latest OpenGL Drivers 11-8 vii 12 Java 2D Generic Performance Issues 12-1 Hardware-Accelerated Rendering Primitives 12-1 Primitive Tracing to Detect and Avoid Non-Accelerated Rendering 12-2 Causes of Poor Rendering Performance 12-3 Improve Performance of Software-only Rendering 12-5 Text-Related Issues 12-6 Application Crash During Text Rendering 12-6 Differences in Text Appearance 12-8 Metrics 12-9 Java 2D Printing 12-10 13 Swing General Debug Tips for Swing 13-1 Specific Debug Tips for Swing 13-2 Incorrect Threading 13-2 JComponent Children Overlap