SlideShare a Scribd company logo
Taming the
     JVM
Tuning Tools/Techniques

       Mike Prasad

  Or downright grimacing!
      ..can be adventurous!
Objectives
!   Application challenges
!   JVM Configuration
!   Heap Analysis Tools
!   Future/Alternate Solutions
!   Case Study
Application Challenges

!  Java environment dramatically
   changed


!  Multi-core, multi-GB environments


!  Understanding JVM important
Java Memory
!   Divided into two areas – Stack & Heap


Stack
  !   associated with methods
  !   intermediate calcs


Heap
  !   All objects created using “new” keyword
  !   GC responsible for cleaning dead/unwanted objects
  !   Heap sizes controlled by command line options
Java Garbage Collector

!   Objects either in young or tenured generations


!   Minor GC when young objects die


!   Surviving objects moved to tenured gen


!   Full GC when tenured gen needs to be collected
         http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
Generation Sizing

!  Default values typically used


!  This not always sufficient


!  Requires adjusting generation
   size
VM Options
New Space
Behavioral
Stack
-XX:NewSize
-XX:-UseConcMarkSweepGC    new gen heap size
                           old gen concurrent mark-sweep
-Xss
-XX:MaxNewSize
-XX:-UseParallelGC size
          set stack        parallel garbage collection
                           max new gen heap size
-XX:-UseSerialGC           serial garbage collection
-XX:NewRatio               ratio of new/old gen size

-XX:SurvivorRatio          eden/survivor space size
                            Heap

       Debugging            -Xms     initial heap size
        Perm Space
       -XX:-PrintConcurrentLocks
                      -Xmx maximum heap size
                               Prints concurrent           locks
         -XX:PermSize    initial perm size
       -XX:-PrintGCTimeStamps           Print timestamps at gc

                            -Xmn
         -XX:MaxPermSize max perm generation heap size
       -XX:-PrintTenuringDistributionyoung size
                                        Print tenuring age info


         -Xnoclassgc              eliminates load/unload overhead
Memory Analysis Tools
!   JMap
!   JConsole
!   Visual GC
!   JRockit Mission Control
!   Others
   !   JStat
   !   HPROF
jmap
!   Prints memory–related statistics


!   Other options
  !   –heap
  !   –histo
  !   -permstat



!   To programmatically monitor use:
   - java.lang.Runtime.totalMemory()

   - java.lang.Runtime.freeMemory()
jmap-heap

 Used to obtain :
   !   gc name
   !   algorithm details
     !   #threads used for parallel gc
     !   heap configuration
     !   heap usage summary
jmap -histo
!  Class-wise histogram of the heap


!  Prints out:
  !  the number of instances
  !  total amount of memory consumed
  !  the fully qualified class name
jmap -permstat

!   Get perm gen statistics


!   Configuring perm gen size important


!   Web apps load large number of classes
    (JPs etc)


!   “too many” classes = OutOfMemoryError
JConsole

!   Monitoring and management tool


!   JMX–compliant attaches to a running JVM


!   JDK 5.0 and above
Visual GC

!   Monitors
   !   Garbage Collector
   !   Compiler
   !   Class loader



!   Superior to JConsole
JRockit Mission Control

!   Associated with JRockit JVM


!   Tool Suite :
  –  visualize gc and other perf stats
  –  runtime performance profiling tool
  –  memory-analysis tool
Future
!   G1 a new GC in JDK 7


Supports
  !   Parallelism : Uses all available CPUs


  !   Generational: same as HotSpot GC's


  !   Compaction   : performs heap compaction
Appliance Solution

!   Theoretical heap limit of 32-bit JVM is 4G


!   Azul appliance provides
  !   hardware-assisted pauseless gc feature


!   Up to 864 cores with 768GB heap!


!   Xfer workload from app server to appliance
Case Study

!  JEE App – Struts/EJB
!  On WebLogic
!  High volume app
!  Overnight performance issues
!  Full GCs every 1.5 minutes
Case Study
Original VM Settings
  Attempted # of Settings
     -Server
  -XX:-UseConcMarkSweepGC
      –Xms2048M
ProblemPizza + ?
        solved Coke = solution
  -XX:-UseParallelGC
      –Xmx2048M
         ,    , нет , nein, αριθ.
  -XX:-UseHailMaryGC (made it
     –Xmn512M                       worse!)

       Problem was with the code!
Moral FinallyStory
            Of the
Apply rigor forJVM, test, the developer! test
 Don’t lookthe unit tamein the wrong place!
     Spare  –    garbage  profile, load




               Why women live longer!
Taming The JVM

More Related Content

Viewers also liked (8)

PPTX
Futuristic programing language
Mohamed Zaki
 
PDF
Job Hunting Under Duress
Matthew McCullough
 
PDF
E-Commerce Thrills and Spills
Matthew McCullough
 
PDF
Agile Estimation
Matthew McCullough
 
PDF
Using Git and GitHub Effectively at Emerge Interactive
Matthew McCullough
 
PDF
Principles Of Programing Languages
Matthew McCullough
 
PDF
Git Going With DVCS v1.1
Matthew McCullough
 
PDF
Adam Smith Builds an App
Matthew McCullough
 
Futuristic programing language
Mohamed Zaki
 
Job Hunting Under Duress
Matthew McCullough
 
E-Commerce Thrills and Spills
Matthew McCullough
 
Agile Estimation
Matthew McCullough
 
Using Git and GitHub Effectively at Emerge Interactive
Matthew McCullough
 
Principles Of Programing Languages
Matthew McCullough
 
Git Going With DVCS v1.1
Matthew McCullough
 
Adam Smith Builds an App
Matthew McCullough
 

Similar to Taming The JVM (20)

PDF
Basics of JVM Tuning
Vladislav Gangan
 
PDF
Introduction of Java GC Tuning and Java Java Mission Control
Leon Chen
 
PDF
[BGOUG] Java GC - Friend or Foe
SAP HANA Cloud Platform
 
PPTX
Jvm & Garbage collection tuning for low latencies application
Quentin Ambard
 
PPTX
JVM Magic
Baruch Sadogursky
 
PDF
JVM and Garbage Collection Tuning
Kai Koenig
 
PDF
Performance Tuning - Understanding Garbage Collection
Haribabu Nandyal Padmanaban
 
PPTX
Java performance tuning
Mohammed Fazuluddin
 
PDF
Tuning IBMs Generational GC
Chris Bailey
 
PPT
Performance tuning jvm
Prem Kuppumani
 
PDF
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
Haim Yadid
 
PDF
A quick view about Java Virtual Machine
João Santana
 
PDF
Native Code & Off-Heap Data Structures for Solr: Presented by Yonik Seeley, H...
Lucidworks
 
PPTX
JVM @ Taobao - QCon Hangzhou 2011
Kris Mok
 
PPTX
Memory Management: What You Need to Know When Moving to Java 8
AppDynamics
 
PDF
JVM Garbage Collection Tuning
ihji
 
PDF
Java Performance and Using Java Flight Recorder
Isuru Perera
 
PPTX
Jvm problem diagnostics
Danijel Mitar
 
PPTX
jvm.pptx
senthilnathan662693
 
PDF
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
Jelastic Multi-Cloud PaaS
 
Basics of JVM Tuning
Vladislav Gangan
 
Introduction of Java GC Tuning and Java Java Mission Control
Leon Chen
 
[BGOUG] Java GC - Friend or Foe
SAP HANA Cloud Platform
 
Jvm & Garbage collection tuning for low latencies application
Quentin Ambard
 
JVM and Garbage Collection Tuning
Kai Koenig
 
Performance Tuning - Understanding Garbage Collection
Haribabu Nandyal Padmanaban
 
Java performance tuning
Mohammed Fazuluddin
 
Tuning IBMs Generational GC
Chris Bailey
 
Performance tuning jvm
Prem Kuppumani
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
Haim Yadid
 
A quick view about Java Virtual Machine
João Santana
 
Native Code & Off-Heap Data Structures for Solr: Presented by Yonik Seeley, H...
Lucidworks
 
JVM @ Taobao - QCon Hangzhou 2011
Kris Mok
 
Memory Management: What You Need to Know When Moving to Java 8
AppDynamics
 
JVM Garbage Collection Tuning
ihji
 
Java Performance and Using Java Flight Recorder
Isuru Perera
 
Jvm problem diagnostics
Danijel Mitar
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
Jelastic Multi-Cloud PaaS
 
Ad

More from Matthew McCullough (20)

PDF
All About GitHub Pull Requests
Matthew McCullough
 
PDF
Git's Filter Branch Command
Matthew McCullough
 
PDF
Git Graphs, Hashes, and Compression, Oh My
Matthew McCullough
 
PDF
Git and GitHub at the San Francisco JUG
Matthew McCullough
 
PDF
Finding Things in Git
Matthew McCullough
 
PDF
Git and GitHub for RallyOn
Matthew McCullough
 
PDF
Migrating from Subversion to Git and GitHub
Matthew McCullough
 
PDF
Git Notes and GitHub
Matthew McCullough
 
PDF
Intro to Git and GitHub
Matthew McCullough
 
PDF
Build Lifecycle Craftsmanship for the Transylvania JUG
Matthew McCullough
 
PDF
Git Going for the Transylvania JUG
Matthew McCullough
 
PDF
Transylvania JUG Pre-Meeting Announcements
Matthew McCullough
 
PDF
Game Theory for Software Developers at the Boulder JUG
Matthew McCullough
 
PDF
Cascading Through Hadoop for the Boulder JUG
Matthew McCullough
 
PDF
JQuery Mobile
Matthew McCullough
 
PDF
R Data Analysis Software
Matthew McCullough
 
PDF
Please, Stop Using Git
Matthew McCullough
 
PDF
Dr. Strangedev
Matthew McCullough
 
PDF
Jenkins for One
Matthew McCullough
 
PDF
Lean Fluffy Startups
Matthew McCullough
 
All About GitHub Pull Requests
Matthew McCullough
 
Git's Filter Branch Command
Matthew McCullough
 
Git Graphs, Hashes, and Compression, Oh My
Matthew McCullough
 
Git and GitHub at the San Francisco JUG
Matthew McCullough
 
Finding Things in Git
Matthew McCullough
 
Git and GitHub for RallyOn
Matthew McCullough
 
Migrating from Subversion to Git and GitHub
Matthew McCullough
 
Git Notes and GitHub
Matthew McCullough
 
Intro to Git and GitHub
Matthew McCullough
 
Build Lifecycle Craftsmanship for the Transylvania JUG
Matthew McCullough
 
Git Going for the Transylvania JUG
Matthew McCullough
 
Transylvania JUG Pre-Meeting Announcements
Matthew McCullough
 
Game Theory for Software Developers at the Boulder JUG
Matthew McCullough
 
Cascading Through Hadoop for the Boulder JUG
Matthew McCullough
 
JQuery Mobile
Matthew McCullough
 
R Data Analysis Software
Matthew McCullough
 
Please, Stop Using Git
Matthew McCullough
 
Dr. Strangedev
Matthew McCullough
 
Jenkins for One
Matthew McCullough
 
Lean Fluffy Startups
Matthew McCullough
 
Ad

Recently uploaded (20)

PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
Dimensions of Societal Planning in Commonism
StefanMz
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 

Taming The JVM

  • 1. Taming the JVM Tuning Tools/Techniques Mike Prasad Or downright grimacing! ..can be adventurous!
  • 2. Objectives !   Application challenges !   JVM Configuration !   Heap Analysis Tools !   Future/Alternate Solutions !   Case Study
  • 3. Application Challenges !  Java environment dramatically changed !  Multi-core, multi-GB environments !  Understanding JVM important
  • 4. Java Memory !   Divided into two areas – Stack & Heap Stack !   associated with methods !   intermediate calcs Heap !   All objects created using “new” keyword !   GC responsible for cleaning dead/unwanted objects !   Heap sizes controlled by command line options
  • 5. Java Garbage Collector !   Objects either in young or tenured generations !   Minor GC when young objects die !   Surviving objects moved to tenured gen !   Full GC when tenured gen needs to be collected http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
  • 6. Generation Sizing !  Default values typically used !  This not always sufficient !  Requires adjusting generation size
  • 7. VM Options New Space Behavioral Stack -XX:NewSize -XX:-UseConcMarkSweepGC new gen heap size old gen concurrent mark-sweep -Xss -XX:MaxNewSize -XX:-UseParallelGC size set stack parallel garbage collection max new gen heap size -XX:-UseSerialGC serial garbage collection -XX:NewRatio ratio of new/old gen size -XX:SurvivorRatio eden/survivor space size Heap Debugging -Xms initial heap size Perm Space -XX:-PrintConcurrentLocks -Xmx maximum heap size Prints concurrent locks -XX:PermSize initial perm size -XX:-PrintGCTimeStamps Print timestamps at gc -Xmn -XX:MaxPermSize max perm generation heap size -XX:-PrintTenuringDistributionyoung size Print tenuring age info -Xnoclassgc eliminates load/unload overhead
  • 8. Memory Analysis Tools !   JMap !   JConsole !   Visual GC !   JRockit Mission Control !   Others !   JStat !   HPROF
  • 9. jmap !   Prints memory–related statistics !   Other options !   –heap !   –histo !   -permstat !   To programmatically monitor use: - java.lang.Runtime.totalMemory() - java.lang.Runtime.freeMemory()
  • 10. jmap-heap Used to obtain : !   gc name !   algorithm details !   #threads used for parallel gc !   heap configuration !   heap usage summary
  • 11. jmap -histo !  Class-wise histogram of the heap !  Prints out: !  the number of instances !  total amount of memory consumed !  the fully qualified class name
  • 12. jmap -permstat !   Get perm gen statistics !   Configuring perm gen size important !   Web apps load large number of classes (JPs etc) !   “too many” classes = OutOfMemoryError
  • 13. JConsole !   Monitoring and management tool !   JMX–compliant attaches to a running JVM !   JDK 5.0 and above
  • 14. Visual GC !   Monitors !   Garbage Collector !   Compiler !   Class loader !   Superior to JConsole
  • 15. JRockit Mission Control !   Associated with JRockit JVM !   Tool Suite : –  visualize gc and other perf stats –  runtime performance profiling tool –  memory-analysis tool
  • 16. Future !   G1 a new GC in JDK 7 Supports !   Parallelism : Uses all available CPUs !   Generational: same as HotSpot GC's !   Compaction : performs heap compaction
  • 17. Appliance Solution !   Theoretical heap limit of 32-bit JVM is 4G !   Azul appliance provides !   hardware-assisted pauseless gc feature !   Up to 864 cores with 768GB heap! !   Xfer workload from app server to appliance
  • 18. Case Study !  JEE App – Struts/EJB !  On WebLogic !  High volume app !  Overnight performance issues !  Full GCs every 1.5 minutes
  • 19. Case Study Original VM Settings Attempted # of Settings -Server -XX:-UseConcMarkSweepGC –Xms2048M ProblemPizza + ? solved Coke = solution -XX:-UseParallelGC –Xmx2048M , , нет , nein, αριθ. -XX:-UseHailMaryGC (made it –Xmn512M worse!) Problem was with the code!
  • 20. Moral FinallyStory Of the Apply rigor forJVM, test, the developer! test Don’t lookthe unit tamein the wrong place! Spare – garbage profile, load Why women live longer!