SlideShare a Scribd company logo
1 of 27
Download to read offline
IBM Software Group




What your JVM has been trying to tell you…



         A look at available PD options within the IBM JVM




         May 2007 | John Pape, IBM WebSphere SWAT       © 2008 IBM Corporation
IBM Java Technology




Agenda

     JVM Overview
     JVM Components
     Problem Scenarios
     Summary
     References




2                         © 2007 IBM Corporation
IBM Java Technology




                          JVM Overview




3                                        © 2007 IBM Corporation
IBM Java Technology




JVM Overview
      JVM = A Java Virtual Machine (JVM) is a virtual machine that
       interprets and executes Java bytecode. (compiled Java
       programs)
      It is a program/process like any other.
      Virtual Machine = software that creates a virtualized
       environment between the computer platform and its operating
       system, so that the end user can operate software on an
       abstract machine.
       The JVM allows a developer to write Java code and compile
       it, one time, and then deploy that bytecode to any JVM on
       any platform and have it run basically the same way.
      The JVM abstracts OS level functionality and programming
       interfaces from the Java developer.
4                                                           © 2007 IBM Corporation
IBM Java Technology




JVM Overview cont…
                                     Java              Java
                                     App               App
                    Java
                    App               3rd party libraries

                  Java language libraries (I.e java.*, javax.*)


                             Java Virtual Machine
                                  Abstraction

                           Operating System APIs



                           Operating System Kernel



5                                                                 © 2007 IBM Corporation
IBM Java Technology




                      JVM Components




6                                      © 2007 IBM Corporation
IBM Java Technology




Components of the JVM
                                    Object Request
                                     Broker (ORB)
         Java Class                                           Java Class
          Libraries                                           Extensions
                                    Java and JNI code
                                       Native Code


     Core Interface (CI)     Execution Management (XM)       Native Libraries

                                              Lock (LK)
    Classloader       Data
       (CL)       Conversion (dc)
                                               Storage       Just In Time
    Execution      Diagnostics                  (ST)         Compiler (JIT)
    Engine(XE)        (dg)

           HPI (Hardware Platform Interface)

                                 Operating System Platform
7                                                                     © 2007 IBM Corporation
IBM Java Technology




Core Interface
       This subcomponent encapsulates all interaction with the
        user, external programs, and operating environment. It is
        responsible for initiation of the JVM.
        Provides presentation (but not execution) of all external APIs
        (for example, JNI, JVMDI, JVMPI)
       Processes command-line input
       Provides internal APIs to enable other sub-components to
        interact with the console
       Holds routines for interacting with the console; nominally,
        standard in, out, and err
       Provides support for issuing formatted messages that are
        suitable for NLS
       Holds routines for accessing the system properties

8                                                               © 2007 IBM Corporation
IBM Java Technology




Execution Engine

      This subcomponent provides all methods of executing Java
       byte codes, both compiled and interpretive.
      Executes the byte code (in whatever form)
      Calls native method routines
      Contains and defines byte code compiler (JIT) interfaces
      Provides support for math functions that the byte code
       requires
      Provides support for raising Java exceptions




9                                                               © 2007 IBM Corporation
IBM Java Technology




Execution Management

      This subcomponent provides process control and
       management of multiple execution engines. Is
       initiated by the core interface. It provides:
      Threading facilities
      Runtime configuration; setting and inquiry
      Support for raising internal exceptions
      End JVM processing
      Support for the resolution and loading of native
       methods

10                                                   © 2007 IBM Corporation
IBM Java Technology




Diagnostics

       This subcomponent provides all diagnostic and debug
        services and facilities. It is also responsible for providing
        methods for raising events.
       Support for issuing events
       Implementation of debug APIs v Trace facilities
       Reliability, availability, and serviceability (RAS) facilities
       First failure data capture (FFDC) facilities




11                                                                   © 2007 IBM Corporation
IBM Java Technology




Class Loader

       This subcomponent provides all support functions to Java
        classes, except the execution.
       Loading classes
       Resolution of classes
       Verification of classes
       Initialization of classes
       Methods for interrogation of class abilities
       Implementation of reflection APIs




12                                                           © 2007 IBM Corporation
IBM Java Technology




Data Conversion

       This subcomponent provides support for converting data
        between various formats.
       UTF Translation
       String conversion
       Support for primitive types




13                                                          © 2007 IBM Corporation
IBM Java Technology




Lock

         This subcomponent provides locking and synchronization
          services.
         Maintains Java lock monitors
         Manages thread locking in the JVM
         Provides report on deadlocks in Java thread dumps
         Provides report on monitor pool in Java thread dumps




14                                                               © 2007 IBM Corporation
IBM Java Technology




Storage

       This subcomponent encapsulates all support for storage
        services.
       Facilities to create, manage, and destroy discrete units of
        storage
       Specific allocation strategies
       The Java object store (garbage collectable heap)




15                                                              © 2007 IBM Corporation
IBM Java Technology




Hardware Platform Interface

       This subcomponent consists of a set of well-defined functions
        that provide low-level facilities and services in a platform-
        neutral way.
       The HPI is an external interface that is defined by Sun.




16                                                             © 2007 IBM Corporation
IBM Java Technology




                           Problem
                           Scenarios




17                                     © 2007 IBM Corporation
IBM Java Technology




Problem Scenarios

      My application is running       What does my memory
       slow when running a certain      footprint look like for my
       code path, why?                  application?

      My application has very         Which parts of my application
                                        consume the most CPU time?
       erratic response times;
       sometimes it’s great, others    Which parts of my application
       it’s terrible, why?              are taking up the most
                                        memory?
      I am getting out of memory
       errors on my application due    Is my application performance
       to heap fragmentation, how       as result of synchronization
       can I tell what objects are      problems in my threads?
       pinned and dosed?               I need to know the exact
                                        activities of the JVM when a
                                        certain method is executed.
18                                                               © 2007 IBM Corporation
IBM Java Technology




My application is running slow when executing a certain
code path, why?
      This problem can be approached by setting a JVM method trace.
        – Example:
            – Database calls are slow when called from my stateless session EJB. The database class is
              com.mycorp.db.DatabaseWrapper and the EJB is com.mycorp.ejb.session.LogicBean.
            – The following trace could be enabled on the JVM (the –D parameters are delimited by spaces, there is
              no line break)
                 – -Dibm.dg.trc.maximal=mt –
                    Dibm.dg.trc.methods=com/mycorp/db/DatabaseWrapper.*(),com/mycorp/ejb/session/LogicBean.*
                    () –Dibm.dg.trc.output=/tmp/jvm.trc
            – JVM tracing incurs overhead and can produce large quantities of data, very rapidly. It is best to test the
              code path with a single request to minimize any concerns with disk space usage.
            – After taking the trace, it cannot be read until formatted. To do this you must execute the TraceFormat
              tool contained in the IBM JDK.
                 – java com.ibm.jvm.format.TraceFormat <trace file> -indent
                       – -indent is used to provide helpful formatting of the nested levels of method tracing
                       – Timestamps printed in the JVM trace are in UTC format. This means you must translate the
                         times into your time zone.
      The net result of this tracing is an EXACT code path taken in the application. It may
       be beneficial to add some other classes or packages to the trace to obtain a clear
       overall picture (e.g. include some WebSphere Resource Adapter classes to see
       server activity around the application calls)




19                                                                                                          © 2007 IBM Corporation
IBM Java Technology




My application has very erratic response times; sometimes
it’s great, others it’s terrible, why?
       This problem can be approached in 2 ways:
          – 1. JVM method trace
          – 2. Enable and analyze verbose garbage collection (GC) output
       Since JVM method tracing has been demonstrated already, we’ll focus on
        verbose GC analysis
          – To enable verbose GC:
              – Add –verbosegc or –verbose:gc to JVM arguments
                  – WebSphere has a check box to tick off, other servers/products
                    may have similar methods on enablement
              – Use –Xverbosegclog:/path/to/desired/gcfile.txt to specify a file to
                output verbose GC data to.
              – By default, verbose GC outputs to native_stderr.log. It is also possible
                to create rolling, generational verbose GC logs. Consult the IBM JVM
                Diagnostic Guide for your version of JDK for details.


20                                                                             © 2007 IBM Corporation
IBM Java Technology




I am getting out of memory errors on my application due to
heap fragmentation, how can I tell what objects are pinned
and dosed?
        Pinned Object = Objects on the heap that are permanently immobile until
         explicitly unpinned by JNI. Moving a pinned object would cause a null pointer
         in the native code referencing it.
        Dosed Object = Objects on the heap that are temporarily immobile.

        Pinned and Dosed objects cannot move and thus cannot be compacted
         thereby reducing the overall amount of contiguous free space in memory.
        Useful traces
           – Add -Dibm.dg.trc.print=st_verify
               • Displays the # of pinned/dosed objects on the heap
           – Add -Dibm.dg.trc.print=st_compact_verbose
               • Displays the pinned/dosed objects on the heap during GC
                 compaction
        Knowing the layout of the objects on the heap can help you troubleshoot
         OutOfMemoryErrors as well.
21                                                                           © 2007 IBM Corporation
IBM Java Technology




What does my memory footprint look like for my
application?
      Heapdumps are the primary means                   Heapdumps on JDK 1.4.1 SR1 and
       of viewing memory heap contents.                   later explicitly do a GC before dumping,
                                                          this assures that only live objects are in
      To enable signal-based heapdumps                   the heapdump.
       – that is heapdumps that produced
       on a kill -3 signal:                              Heapdumps are representations of
                                                          memory, so if the JVM has a large
        – Add an environment entry called                 heap size, expect a large dump.
          IBM_HEAPDUMP with a value of true
        – Heapdumps can also be called from Java         Heapdumps can be produced in binary
          code                                            (.phd) format or in text (.txt) format.
            – E.g. com.ibm.jvm.Dump.HeapDump();

      Heapdumps will be produced when a                 The Sun HotSpot JVMs handle
                                                          heapdump generation differently and
       JVM exhausts its Java heap and                     have different parameters to invoke.
       throws an OutOfMemoryException.                    Consult with the references section of
        – To disable this behavior: add environment       this presentation for more information.
          entry IBM_HEAPDUMP_OUTOFMEMORY
          with a value of false (same can be done for
          javacores/javadumps –
          IBM_JAVADUMP_OUTOFMEMORY=false)
        – On older JVM’s you may need to set this
          value in order to produce heapdumps on an
          OutOfMemoryException



22                                                                                       © 2007 IBM Corporation
IBM Java Technology




Which parts of my application consume the most CPU
time?
       Using the HPROF profiler, included with the JDK, you can determine which
        methods are consuming the most CPU time.

       To invoke HPROF:
          – Add –Xrunhprof:<name>=<value> / where <name> and <value> are
            name/value pairs of HPROF parameters
          – To obtain CPU calculations:
              – -Xrunhprof:cpu=samples
          – To obtain greater detail (with a performance trade-off)
              – -Xrunhprof:cpu=timings
       EPROF can be executed on SUN HotSpot JVM's
          – -Xeprof
       Running HPROF can result in an unstable JVM which can crash
        unexpectedly, use with caution (not for production environments)



23                                                                         © 2007 IBM Corporation
IBM Java Technology




Which parts of my application are taking up the most
memory?
        The HPROF profiler can assist here once again
           – To obtain data on memory allocations by method:
               – Add –Xrunhprof:heap=sites
        HPROF will provide a sorted list of sites with the most heavily
         allocated objects at the top.
        This data will show you were the “hot spots” are in the code, that is,
         the places in the code path that is responsible for the generation of
         new objects.
        Useful for determining what part of the application is contributing the
         most to the overall memory footprint.
        Can be used to stem potential memory leaks way before they
         become an issue.


24                                                                      © 2007 IBM Corporation
IBM Java Technology




Is my application performance a result of synchronization
problems in my threads?
       HPROF can be used here once again
           – To collect thread and synchronization data from the
             JVM:
               – Add –Xrunhprof:monitor=y,thread=y
       This setup will provide data shows how much time
        threads are waiting to access resources that are
        already locked (resource contention)
       It also provides a list of active monitors in the JVM,
        this info can be useful to determine the presence of
        deadlocks.

25                                                         © 2007 IBM Corporation
IBM Java Technology




I need to know the exact activities of the JVM when a
certain method is executed.
        In this case, you need to trigger a dump of some kind on a specific
         trigger.
        The JVM can be setup to trigger several different types of dumps on
         many conditions:
           – Example : trigger java dump on uncaught
             ArrayIndexOutOfBoundsException
           – -Xdump:java:events=uncaught,filter=*ArrayIndexOutOfBoundsException*
        Types of dumps that can be produced
           – Java dump / Java core / thread dump
           – Heap dump
           – Core dump / System dump
           – Snap trace
           – Stack dump (JDK 5 SR10 and onwards)


26                                                                      © 2007 IBM Corporation
IBM Java Technology




                           Thanks!




27                                   © 2007 IBM Corporation

More Related Content

What's hot

Introduction to java_ee
Introduction to java_eeIntroduction to java_ee
Introduction to java_ee
Yogesh Bindwal
 
EJB 3.1 by Bert Ertman
EJB 3.1 by Bert ErtmanEJB 3.1 by Bert Ertman
EJB 3.1 by Bert Ertman
Stephan Janssen
 
Jax london 2011
Jax london 2011Jax london 2011
Jax london 2011
njbartlett
 
Lab 1) rad installation
Lab 1) rad installationLab 1) rad installation
Lab 1) rad installation
techbed
 

What's hot (20)

Designing JEE Application Structure
Designing JEE Application StructureDesigning JEE Application Structure
Designing JEE Application Structure
 
01.egovFrame Training Book II
01.egovFrame Training Book II01.egovFrame Training Book II
01.egovFrame Training Book II
 
Plugin-able POS Solutions by Javascript @HDM9 Taiwan
Plugin-able POS Solutions by Javascript @HDM9 TaiwanPlugin-able POS Solutions by Javascript @HDM9 Taiwan
Plugin-able POS Solutions by Javascript @HDM9 Taiwan
 
Architecture | Modular Enterprise Applications | Mark Nuttall
Architecture | Modular Enterprise Applications | Mark NuttallArchitecture | Modular Enterprise Applications | Mark Nuttall
Architecture | Modular Enterprise Applications | Mark Nuttall
 
Java 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaJava 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kollipara
 
02.egovFrame Development Environment training book
02.egovFrame Development Environment training book02.egovFrame Development Environment training book
02.egovFrame Development Environment training book
 
Introduction to java_ee
Introduction to java_eeIntroduction to java_ee
Introduction to java_ee
 
3978 Why is Java so different... A Session for Cobol/PLI/Assembler Developers
3978   Why is Java so different... A Session for Cobol/PLI/Assembler Developers3978   Why is Java so different... A Session for Cobol/PLI/Assembler Developers
3978 Why is Java so different... A Session for Cobol/PLI/Assembler Developers
 
EJB 3.1 by Bert Ertman
EJB 3.1 by Bert ErtmanEJB 3.1 by Bert Ertman
EJB 3.1 by Bert Ertman
 
Jax london 2011
Jax london 2011Jax london 2011
Jax london 2011
 
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
 
04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop
 
Lab 1) rad installation
Lab 1) rad installationLab 1) rad installation
Lab 1) rad installation
 
1006 Z2 Intro Complete
1006 Z2 Intro Complete1006 Z2 Intro Complete
1006 Z2 Intro Complete
 
Sotona
SotonaSotona
Sotona
 
Quality on Submit
Quality on SubmitQuality on Submit
Quality on Submit
 
Windows Azure Interoperability
Windows Azure InteroperabilityWindows Azure Interoperability
Windows Azure Interoperability
 
JavaEE6
JavaEE6JavaEE6
JavaEE6
 
Concierge - Bringing OSGi (back) to Embedded Devices
Concierge - Bringing OSGi (back) to Embedded DevicesConcierge - Bringing OSGi (back) to Embedded Devices
Concierge - Bringing OSGi (back) to Embedded Devices
 
03.eGovFrame Runtime Environment Training Book Supplement
03.eGovFrame Runtime Environment Training Book Supplement03.eGovFrame Runtime Environment Training Book Supplement
03.eGovFrame Runtime Environment Training Book Supplement
 

Viewers also liked

احمد غزالي
احمد غزالياحمد غزالي
احمد غزالي
raniarafat
 
Canyonz Bouldering Slide
Canyonz Bouldering SlideCanyonz Bouldering Slide
Canyonz Bouldering Slide
Jamie Carter
 
Woman's dreams
Woman's  dreamsWoman's  dreams
Woman's dreams
AMANDA LEK
 

Viewers also liked (20)

Corporativo patronato uaeh
Corporativo patronato uaehCorporativo patronato uaeh
Corporativo patronato uaeh
 
CV Werk
CV WerkCV Werk
CV Werk
 
Moving From Small Science To Big Science
Moving From Small Science To Big ScienceMoving From Small Science To Big Science
Moving From Small Science To Big Science
 
SWAN Day program details
SWAN Day program detailsSWAN Day program details
SWAN Day program details
 
Background Highlights 3252016
Background Highlights 3252016Background Highlights 3252016
Background Highlights 3252016
 
احمد غزالي
احمد غزالياحمد غزالي
احمد غزالي
 
Report Gus
Report GusReport Gus
Report Gus
 
Expocomp
ExpocompExpocomp
Expocomp
 
Level2 photo-w-commentary NZQA slide show
Level2 photo-w-commentary NZQA slide showLevel2 photo-w-commentary NZQA slide show
Level2 photo-w-commentary NZQA slide show
 
Industria
IndustriaIndustria
Industria
 
Westcott Pro Photo Intro
Westcott Pro Photo IntroWestcott Pro Photo Intro
Westcott Pro Photo Intro
 
Kurikulum Viti
Kurikulum VitiKurikulum Viti
Kurikulum Viti
 
0102 01 พัฒนาการของตรรกศาสตร์
0102 01 พัฒนาการของตรรกศาสตร์0102 01 พัฒนาการของตรรกศาสตร์
0102 01 พัฒนาการของตรรกศาสตร์
 
PAC1
PAC1PAC1
PAC1
 
ιστορια
ιστοριαιστορια
ιστορια
 
Spago BI
Spago BISpago BI
Spago BI
 
Canyonz Bouldering Slide
Canyonz Bouldering SlideCanyonz Bouldering Slide
Canyonz Bouldering Slide
 
0102 02 ประพจน์
0102 02 ประพจน์0102 02 ประพจน์
0102 02 ประพจน์
 
Bio Andorgal
Bio AndorgalBio Andorgal
Bio Andorgal
 
Woman's dreams
Woman's  dreamsWoman's  dreams
Woman's dreams
 

Similar to What Your Jvm Has Been Trying To Tell You

J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01
Jay Palit
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
WE-IT TUTORIALS
 
Great cup of java
Great  cup of javaGreat  cup of java
Great cup of java
CIB Egypt
 

Similar to What Your Jvm Has Been Trying To Tell You (20)

Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
02-Java Technology Details.ppt
02-Java Technology Details.ppt02-Java Technology Details.ppt
02-Java Technology Details.ppt
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
 
Java session2
Java session2Java session2
Java session2
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
JVM.pptx
JVM.pptxJVM.pptx
JVM.pptx
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Java the reason behind its never ending demand
Java the reason behind its never ending demandJava the reason behind its never ending demand
Java the reason behind its never ending demand
 
Java Starting
Java StartingJava Starting
Java Starting
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
 
Great cup of java
Great  cup of javaGreat  cup of java
Great cup of java
 
Java Introduction | PDF
Java Introduction |  PDFJava Introduction |  PDF
Java Introduction | PDF
 
50120140507001 2
50120140507001 250120140507001 2
50120140507001 2
 
50120140507001
5012014050700150120140507001
50120140507001
 
Java1
Java1Java1
Java1
 
Java
Java Java
Java
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
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
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

What Your Jvm Has Been Trying To Tell You

  • 1. IBM Software Group What your JVM has been trying to tell you… A look at available PD options within the IBM JVM May 2007 | John Pape, IBM WebSphere SWAT © 2008 IBM Corporation
  • 2. IBM Java Technology Agenda JVM Overview JVM Components Problem Scenarios Summary References 2 © 2007 IBM Corporation
  • 3. IBM Java Technology JVM Overview 3 © 2007 IBM Corporation
  • 4. IBM Java Technology JVM Overview  JVM = A Java Virtual Machine (JVM) is a virtual machine that interprets and executes Java bytecode. (compiled Java programs)  It is a program/process like any other.  Virtual Machine = software that creates a virtualized environment between the computer platform and its operating system, so that the end user can operate software on an abstract machine. The JVM allows a developer to write Java code and compile it, one time, and then deploy that bytecode to any JVM on any platform and have it run basically the same way.  The JVM abstracts OS level functionality and programming interfaces from the Java developer. 4 © 2007 IBM Corporation
  • 5. IBM Java Technology JVM Overview cont… Java Java App App Java App 3rd party libraries Java language libraries (I.e java.*, javax.*) Java Virtual Machine Abstraction Operating System APIs Operating System Kernel 5 © 2007 IBM Corporation
  • 6. IBM Java Technology JVM Components 6 © 2007 IBM Corporation
  • 7. IBM Java Technology Components of the JVM Object Request Broker (ORB) Java Class Java Class Libraries Extensions Java and JNI code Native Code Core Interface (CI) Execution Management (XM) Native Libraries Lock (LK) Classloader Data (CL) Conversion (dc) Storage Just In Time Execution Diagnostics (ST) Compiler (JIT) Engine(XE) (dg) HPI (Hardware Platform Interface) Operating System Platform 7 © 2007 IBM Corporation
  • 8. IBM Java Technology Core Interface  This subcomponent encapsulates all interaction with the user, external programs, and operating environment. It is responsible for initiation of the JVM. Provides presentation (but not execution) of all external APIs (for example, JNI, JVMDI, JVMPI)  Processes command-line input  Provides internal APIs to enable other sub-components to interact with the console  Holds routines for interacting with the console; nominally, standard in, out, and err  Provides support for issuing formatted messages that are suitable for NLS  Holds routines for accessing the system properties 8 © 2007 IBM Corporation
  • 9. IBM Java Technology Execution Engine  This subcomponent provides all methods of executing Java byte codes, both compiled and interpretive.  Executes the byte code (in whatever form)  Calls native method routines  Contains and defines byte code compiler (JIT) interfaces  Provides support for math functions that the byte code requires  Provides support for raising Java exceptions 9 © 2007 IBM Corporation
  • 10. IBM Java Technology Execution Management This subcomponent provides process control and management of multiple execution engines. Is initiated by the core interface. It provides: Threading facilities Runtime configuration; setting and inquiry Support for raising internal exceptions End JVM processing Support for the resolution and loading of native methods 10 © 2007 IBM Corporation
  • 11. IBM Java Technology Diagnostics  This subcomponent provides all diagnostic and debug services and facilities. It is also responsible for providing methods for raising events.  Support for issuing events  Implementation of debug APIs v Trace facilities  Reliability, availability, and serviceability (RAS) facilities  First failure data capture (FFDC) facilities 11 © 2007 IBM Corporation
  • 12. IBM Java Technology Class Loader  This subcomponent provides all support functions to Java classes, except the execution.  Loading classes  Resolution of classes  Verification of classes  Initialization of classes  Methods for interrogation of class abilities  Implementation of reflection APIs 12 © 2007 IBM Corporation
  • 13. IBM Java Technology Data Conversion  This subcomponent provides support for converting data between various formats.  UTF Translation  String conversion  Support for primitive types 13 © 2007 IBM Corporation
  • 14. IBM Java Technology Lock  This subcomponent provides locking and synchronization services.  Maintains Java lock monitors  Manages thread locking in the JVM  Provides report on deadlocks in Java thread dumps  Provides report on monitor pool in Java thread dumps 14 © 2007 IBM Corporation
  • 15. IBM Java Technology Storage  This subcomponent encapsulates all support for storage services.  Facilities to create, manage, and destroy discrete units of storage  Specific allocation strategies  The Java object store (garbage collectable heap) 15 © 2007 IBM Corporation
  • 16. IBM Java Technology Hardware Platform Interface  This subcomponent consists of a set of well-defined functions that provide low-level facilities and services in a platform- neutral way.  The HPI is an external interface that is defined by Sun. 16 © 2007 IBM Corporation
  • 17. IBM Java Technology Problem Scenarios 17 © 2007 IBM Corporation
  • 18. IBM Java Technology Problem Scenarios  My application is running  What does my memory slow when running a certain footprint look like for my code path, why? application?  My application has very  Which parts of my application consume the most CPU time? erratic response times; sometimes it’s great, others  Which parts of my application it’s terrible, why? are taking up the most memory?  I am getting out of memory errors on my application due  Is my application performance to heap fragmentation, how as result of synchronization can I tell what objects are problems in my threads? pinned and dosed?  I need to know the exact activities of the JVM when a certain method is executed. 18 © 2007 IBM Corporation
  • 19. IBM Java Technology My application is running slow when executing a certain code path, why?  This problem can be approached by setting a JVM method trace. – Example: – Database calls are slow when called from my stateless session EJB. The database class is com.mycorp.db.DatabaseWrapper and the EJB is com.mycorp.ejb.session.LogicBean. – The following trace could be enabled on the JVM (the –D parameters are delimited by spaces, there is no line break) – -Dibm.dg.trc.maximal=mt – Dibm.dg.trc.methods=com/mycorp/db/DatabaseWrapper.*(),com/mycorp/ejb/session/LogicBean.* () –Dibm.dg.trc.output=/tmp/jvm.trc – JVM tracing incurs overhead and can produce large quantities of data, very rapidly. It is best to test the code path with a single request to minimize any concerns with disk space usage. – After taking the trace, it cannot be read until formatted. To do this you must execute the TraceFormat tool contained in the IBM JDK. – java com.ibm.jvm.format.TraceFormat <trace file> -indent – -indent is used to provide helpful formatting of the nested levels of method tracing – Timestamps printed in the JVM trace are in UTC format. This means you must translate the times into your time zone.  The net result of this tracing is an EXACT code path taken in the application. It may be beneficial to add some other classes or packages to the trace to obtain a clear overall picture (e.g. include some WebSphere Resource Adapter classes to see server activity around the application calls) 19 © 2007 IBM Corporation
  • 20. IBM Java Technology My application has very erratic response times; sometimes it’s great, others it’s terrible, why?  This problem can be approached in 2 ways: – 1. JVM method trace – 2. Enable and analyze verbose garbage collection (GC) output  Since JVM method tracing has been demonstrated already, we’ll focus on verbose GC analysis – To enable verbose GC: – Add –verbosegc or –verbose:gc to JVM arguments – WebSphere has a check box to tick off, other servers/products may have similar methods on enablement – Use –Xverbosegclog:/path/to/desired/gcfile.txt to specify a file to output verbose GC data to. – By default, verbose GC outputs to native_stderr.log. It is also possible to create rolling, generational verbose GC logs. Consult the IBM JVM Diagnostic Guide for your version of JDK for details. 20 © 2007 IBM Corporation
  • 21. IBM Java Technology I am getting out of memory errors on my application due to heap fragmentation, how can I tell what objects are pinned and dosed?  Pinned Object = Objects on the heap that are permanently immobile until explicitly unpinned by JNI. Moving a pinned object would cause a null pointer in the native code referencing it.  Dosed Object = Objects on the heap that are temporarily immobile.  Pinned and Dosed objects cannot move and thus cannot be compacted thereby reducing the overall amount of contiguous free space in memory.  Useful traces – Add -Dibm.dg.trc.print=st_verify • Displays the # of pinned/dosed objects on the heap – Add -Dibm.dg.trc.print=st_compact_verbose • Displays the pinned/dosed objects on the heap during GC compaction  Knowing the layout of the objects on the heap can help you troubleshoot OutOfMemoryErrors as well. 21 © 2007 IBM Corporation
  • 22. IBM Java Technology What does my memory footprint look like for my application?  Heapdumps are the primary means  Heapdumps on JDK 1.4.1 SR1 and of viewing memory heap contents. later explicitly do a GC before dumping, this assures that only live objects are in  To enable signal-based heapdumps the heapdump. – that is heapdumps that produced on a kill -3 signal:  Heapdumps are representations of memory, so if the JVM has a large – Add an environment entry called heap size, expect a large dump. IBM_HEAPDUMP with a value of true – Heapdumps can also be called from Java  Heapdumps can be produced in binary code (.phd) format or in text (.txt) format. – E.g. com.ibm.jvm.Dump.HeapDump();  Heapdumps will be produced when a  The Sun HotSpot JVMs handle heapdump generation differently and JVM exhausts its Java heap and have different parameters to invoke. throws an OutOfMemoryException. Consult with the references section of – To disable this behavior: add environment this presentation for more information. entry IBM_HEAPDUMP_OUTOFMEMORY with a value of false (same can be done for javacores/javadumps – IBM_JAVADUMP_OUTOFMEMORY=false) – On older JVM’s you may need to set this value in order to produce heapdumps on an OutOfMemoryException 22 © 2007 IBM Corporation
  • 23. IBM Java Technology Which parts of my application consume the most CPU time?  Using the HPROF profiler, included with the JDK, you can determine which methods are consuming the most CPU time.  To invoke HPROF: – Add –Xrunhprof:<name>=<value> / where <name> and <value> are name/value pairs of HPROF parameters – To obtain CPU calculations: – -Xrunhprof:cpu=samples – To obtain greater detail (with a performance trade-off) – -Xrunhprof:cpu=timings  EPROF can be executed on SUN HotSpot JVM's – -Xeprof  Running HPROF can result in an unstable JVM which can crash unexpectedly, use with caution (not for production environments) 23 © 2007 IBM Corporation
  • 24. IBM Java Technology Which parts of my application are taking up the most memory?  The HPROF profiler can assist here once again – To obtain data on memory allocations by method: – Add –Xrunhprof:heap=sites  HPROF will provide a sorted list of sites with the most heavily allocated objects at the top.  This data will show you were the “hot spots” are in the code, that is, the places in the code path that is responsible for the generation of new objects.  Useful for determining what part of the application is contributing the most to the overall memory footprint.  Can be used to stem potential memory leaks way before they become an issue. 24 © 2007 IBM Corporation
  • 25. IBM Java Technology Is my application performance a result of synchronization problems in my threads? HPROF can be used here once again – To collect thread and synchronization data from the JVM: – Add –Xrunhprof:monitor=y,thread=y This setup will provide data shows how much time threads are waiting to access resources that are already locked (resource contention) It also provides a list of active monitors in the JVM, this info can be useful to determine the presence of deadlocks. 25 © 2007 IBM Corporation
  • 26. IBM Java Technology I need to know the exact activities of the JVM when a certain method is executed.  In this case, you need to trigger a dump of some kind on a specific trigger.  The JVM can be setup to trigger several different types of dumps on many conditions: – Example : trigger java dump on uncaught ArrayIndexOutOfBoundsException – -Xdump:java:events=uncaught,filter=*ArrayIndexOutOfBoundsException*  Types of dumps that can be produced – Java dump / Java core / thread dump – Heap dump – Core dump / System dump – Snap trace – Stack dump (JDK 5 SR10 and onwards) 26 © 2007 IBM Corporation
  • 27. IBM Java Technology Thanks! 27 © 2007 IBM Corporation