SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Memory Management
What You Need To Know When Moving to Java 8
Todd Rader, Architect / Sales Engineer
AppDynamics
Market Leadership
175% Bookings
Growth 2013
1000+
Customers
OUR
PLATFORM
Website
download
Rapid
Time to Value
Low cost of
ownership
$
Enterprise
adoption
Scalable -
largest APM
deployments
On-Premise,
SaaS, Hybrid
No professional
Services
84
Net Promoter Score
OUR
APPDYNAMICS
Copyright © 2014 AppDynamics. All rights reserved. 2
Agenda
• Memory Basics
• …with a dive into metaspace
• Fun With Garbage Collectors
• GC bake-off
• Summary/Conclusions
• Q&A
Copyright © 2014 AppDynamics. All rights reserved. 3
Memory Basics: Types of Memory
STACK
• Each thread has its own call stack
• Adjust with -Xss
• 64-bit JVMs need more stack size (8-byte references)
• Default stack size: ????
Java7, jdk1.7.0_51, 64-bit on MacOS 10.9.6
• Call depth before StackOverflowError: 10,827 (consistently)
Java8, jdk1.8.0_05, 64-bit on MacOS 10.9.6
• Call depth before StackOverflowError: 20,000-ish (huh?)
Copyright © 2014 AppDynamics. All rights reserved. 4
Stack (cont’d)
FUN WITH NUMBERS….
• With Java8 default stack size, call depth = 20,000-ish
• Using –Xss1024k, same result (SO: default –Xss=1024k)
• Using –XX:ThreadStackSize=1024, same result (-
XX:ThreadStackSize is another way of expressing –Xss)
Okay, but…
• -Xss512k result: 9000-ish
• Not quite linear!
Need more memory space? Use a smaller –Xss value!
• 200 threads * 512kb/thread = 100 MB saved!
• What is your true stack size requirement?
Copyright © 2014 AppDynamics. All rights reserved. 5
Memory Basics: Types of Memory (cont’d)
HEAP
• Eden/New vs. Survivor vs. Old/Tenured
• “Ideal Object Death Rate”
• Eden >> Old >> Survivor
Copyright © 2014 AppDynamics. All rights reserved. 6
Heap (cont’d)
HEAP
• What is your object survival demography?
• Caching!
• Find out with:
• -XX:+PrintGCDetails
• -XX:+PrintTenuringDistribution
• -XX:+PrintGCTimestamps
• Adjust with:
• -XX:NewRatio=n
– Example: NewRatio=2  (oldGenSize) = 2 * (newGenSize)
• -XX:NewSize=n (minimum)
• -XX:MaxNewSize=n
• -XX:MinFreeHeapRatio=n
• -XX:MaxFreeHeapRatio=n
Copyright © 2014 AppDynamics. All rights reserved. 7
Heap: Java 6 HotSpot
Copyright © 2014 AppDynamics. All rights reserved. 8
Memory Basics: Types of Memory (cont’d)
META
• PermGen in Java 6
• PermGen (sort of) in Java 7
• Metaspace in Java 8
while (true) {
int length = rnd.nextInt(100);
StringBuilder builder = new StringBuilder();
String chars = "abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < length; i++) {
builder.append(chars.charAt(rnd.nextInt(chars.length())));
}
interned.add(builder.toString().intern());
}
What happens when this code is run?
Copyright © 2014 AppDynamics. All rights reserved. 9
Running the code…
JAVA 6
Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
• …in about 8 seconds!
JAVA 7
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
• …and it takes a long time to happen!
JAVA 8
• Similar result as with Java 7
Copyright © 2014 AppDynamics. All rights reserved. 10
What happened???
JAVA 6
PermGen contains:
• Class meta data
• Interned strings
JAVA 7
• Interned strings moved to Metaspace
JAVA 8
• Class meta data also moved to Metaspace
Copyright © 2014 AppDynamics. All rights reserved. 11
Metaspace
REPLACEMENT FOR PERMGEN
• NOT JVM memory – native memory!
• BEA/Oracle JRockit
• IBM JVM
SOME NEW STARTUP FLAGS
• -XX:MetaSpaceSize=n (initial size)
• -XX:MaxMetaSpaceSize=n
• -XX:MaxMetaspaceExpansion=n
• -XX:MaxMetaspaceFreeRatio=n
• No default values for size! Max metaspace size is unlimited :-0
• Say goodbye to PermGen problems……right? Right?
Copyright © 2014 AppDynamics. All rights reserved. 12
More Metaspace
OBSOLETES SOME OLD STARTUP FLAGS
• All of the “-XX:*Perm*” flags
NEW MEMORY POOL OBJECTS
• No more matching on “Perm” for pool name
Copyright © 2014 AppDynamics. All rights reserved. 13
What does this mean?
NO MORE OOM/PERMGEN
• But metaspace errors don’t go away 
• Monitor metaspace, not PermGen
• Use –XX:MaxMetaSpaceSize?
• No  you will never run out of metaspace
• …but your use of native memory can grow unbounded!
• Yes  you merely replace “OutOfMemory: PermGen space” with
“OutOfMemory: Metaspace”
MONITOR METASPACE
• Apps that leak metadata will still leak metadata
• Gobbling up metaspace affects the entire system, not just the JVM
• Remember: native memory!
Copyright © 2014 AppDynamics. All rights reserved. 14
Monitoring Metaspace
COMMERCIAL SOLUTIONS
• Expect (demand!) metaspace monitoring support to go along with
Java 8 support
JAVA MANAGEMENT BEANS
• Update any querying of MBeans to search for Metaspace memory
pool instead of PermGen pools.
JVISUALVM
• Metaspace monitoring supported
• …at least in the jvisualvm that is bundled with Jdk1.8.0_05 on MacOS!
Copyright © 2014 AppDynamics. All rights reserved. 15
Memory Basics: Types of Memory (cont’d)
DIRECT
• sun.misc.Unsafe
• Used by the JDK (nio classes, for example)
• Out of the scope of this talk!
Copyright © 2014 AppDynamics. All rights reserved. 16
Let’s talk garbage…
PARALLEL GC
• Default on Java 7, Java 8
• ParNewGC is the default on Java 6
• Does parallel compaction in Java 6 and 7
• -XX:+UseParallelOldGC option in Java 5
CONCURRENT MARK AND SWEEP GC
• NOT compacting!
• Can be prone to fragmentation of old gen
•  very bad full GCs result
G1GC
• Only use after jdk1.7.0_u4!
• “Experimental” in previous releases
Copyright © 2014 AppDynamics. All rights reserved. 17
The GC Bake-off
GC KILLER PROGRAM
• Allocates lots of java.lang.Objects
• Allocates fewer long Strings
• Keeps objects around for varying lengths of times
• Checks heap memory availability
• When low, thousands of memory references are let go of
• No GC tuning options used
• 15-minute runs (killed with Ctrl-C)
• Java 7 vs. Java 8
Copyright © 2014 AppDynamics. All rights reserved. 18
Java 7, Parallel GC
Copyright © 2014 AppDynamics. All rights reserved. 19
Java 7, Parallel GC
HIGHLIGHTS
• No “-XX” option to enable (default)
• Heap usage varied between 1500-2750 MB
• Reasonable time spent in GC (1.6 seconds/minute)
• No major collections
Copyright © 2014 AppDynamics. All rights reserved. 20
Java 7, ConcMarkSweepGC
Copyright © 2014 AppDynamics. All rights reserved. 21
Java 7, ConcMarkSweepGC
HIGHLIGHTS
• Enabled with –XX:+UseConcMarkSweepGC
• Heap usage held steady around 2000 MB
• Huge amount of time spent in GC (24 seconds/minute!)
• No major collections
Copyright © 2014 AppDynamics. All rights reserved. 22
Java 7, G1GC
Copyright © 2014 AppDynamics. All rights reserved. 23
Java 7, G1GC
HIGHLIGHTS
• Enabled with –XX:+UseG1GC
• Heap usage varied between 750-2800 MB
• Very reasonable time spent in GC (0.6 seconds/minute)
• No major collections
Copyright © 2014 AppDynamics. All rights reserved. 24
The winner for Java 7
G1!
• Less time spent in GC
• Heap usage max barely more than max using Parallel
• CMS max heap usage was only 2000
• CMS min was also near 2000 (very steady)
• Heap usage min best of all three
• No major collections
• BUT:
• Remember, no GC tuning parameters were used
• DO NOT USE G1GC before jdk1.7.0_04
• “Experimental” in prior releases
Copyright © 2014 AppDynamics. All rights reserved. 25
Java 8, Parallel GC
Copyright © 2014 AppDynamics. All rights reserved. 26
Java 8, Parallel GC
HIGHLIGHTS
• Incrementally worse than ParallelGC on Java 7
• Higher max heap (2950 vs. 2750)
• Higher min heap (1700MB vs. 1500MB)
• Roughly the same GC time (1.6 seconds/minute)
• No major collections
Copyright © 2014 AppDynamics. All rights reserved. 27
Java 8, ConcMarkSweepGC
Copyright © 2014 AppDynamics. All rights reserved. 28
Java 8, ConcMarkSweepGC
HIGHLIGHTS
• Just……lousy
• HUGE amount of initial time spent in gc
• 55 seconds/minute!
• Heap usage steadily declined
• From 3000MB to 2000MB
• With all that time spent, you’d think a major collection would be
avoided
• You’d be wrong 
• The only run with a major collection
Copyright © 2014 AppDynamics. All rights reserved. 29
Java 8, G1GC
Copyright © 2014 AppDynamics. All rights reserved. 30
Java 8, G1GC
HIGHLIGHTS
• Incrementally worse than G1/Java 7
• Heap usage max 2850MB vs. 2800MB
• GC time .8 seconds/minute vs. .6 seconds/minute
• No major collections
Copyright © 2014 AppDynamics. All rights reserved. 31
The winner for Java 8, and overall
G1 AGAIN!
• CMS not even close
• G1 on Java 7 overall winner
• Caveats:
• No GC tuning parameters used
• Heap-only: very little metadata memory used
• MacOS 10.9.4 (Maverick’s)
• 2.8 GHz Intel Core i7 processor
• 16 GB 1600 MHz memory
• Java 7: jdk 1.7.0_51 for MacOS
• Java 8: jdk 1.8.0_05 for MacOS
Copyright © 2014 AppDynamics. All rights reserved. 32
GC Tuning
OUT OF SCOPE 
• 600+ “-XX:” options
• 83 for CMS in Java 7
• 82 for CMS in Java 8
• No love for CMSTriggerPermRatio!
• 24 for G1 in Java 7 and 8
• Too many to cover!
Copyright © 2014 AppDynamics. All rights reserved. 33
Summary
• Know your object demography
• Monitor your metaspace
• Interned strings
• Class metadata
• Research the best GC
• Watch out for outdated information
• G1GC tests before jdk1.7.0_04
• Re-think CMS GC?
• Un-tuned CMS results far worse
Copyright © 2014 AppDynamics. All rights reserved. 34
FREE trial available:
www.appdynamics.com
Thank you

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Dvir Volk
 
Hadoop REST API Security with Apache Knox Gateway
Hadoop REST API Security with Apache Knox GatewayHadoop REST API Security with Apache Knox Gateway
Hadoop REST API Security with Apache Knox Gateway
DataWorks Summit
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
Chandler Huang
 

Was ist angesagt? (20)

MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
 
Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
PostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performancePostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performance
 
Top 5 Mistakes When Writing Spark Applications
Top 5 Mistakes When Writing Spark ApplicationsTop 5 Mistakes When Writing Spark Applications
Top 5 Mistakes When Writing Spark Applications
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
 
Intro to HBase
Intro to HBaseIntro to HBase
Intro to HBase
 
Hadoop REST API Security with Apache Knox Gateway
Hadoop REST API Security with Apache Knox GatewayHadoop REST API Security with Apache Knox Gateway
Hadoop REST API Security with Apache Knox Gateway
 
Deploying PostgreSQL on Kubernetes
Deploying PostgreSQL on KubernetesDeploying PostgreSQL on Kubernetes
Deploying PostgreSQL on Kubernetes
 
New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)
New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)
New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)
 
Low latency microservices in java QCon New York 2016
Low latency microservices in java   QCon New York 2016Low latency microservices in java   QCon New York 2016
Low latency microservices in java QCon New York 2016
 
Oracle Active Data Guard: Best Practices and New Features Deep Dive
Oracle Active Data Guard: Best Practices and New Features Deep Dive Oracle Active Data Guard: Best Practices and New Features Deep Dive
Oracle Active Data Guard: Best Practices and New Features Deep Dive
 
APACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsAPACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka Streams
 
Low latency in java 8 v5
Low latency in java 8 v5Low latency in java 8 v5
Low latency in java 8 v5
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
 
Sprytniejsze testowanie kodu java ze spock framework (zaawansowane techniki) ...
Sprytniejsze testowanie kodu java ze spock framework (zaawansowane techniki) ...Sprytniejsze testowanie kodu java ze spock framework (zaawansowane techniki) ...
Sprytniejsze testowanie kodu java ze spock framework (zaawansowane techniki) ...
 
Redis vs Aerospike
Redis vs AerospikeRedis vs Aerospike
Redis vs Aerospike
 
HBaseCon 2015: HBase Performance Tuning @ Salesforce
HBaseCon 2015: HBase Performance Tuning @ SalesforceHBaseCon 2015: HBase Performance Tuning @ Salesforce
HBaseCon 2015: HBase Performance Tuning @ Salesforce
 
Ceph issue 해결 사례
Ceph issue 해결 사례Ceph issue 해결 사례
Ceph issue 해결 사례
 

Andere mochten auch

Java memory presentation
Java memory presentationJava memory presentation
Java memory presentation
Yury Bubnov
 
Sms-Voting and Elections
Sms-Voting and ElectionsSms-Voting and Elections
Sms-Voting and Elections
SergeClause
 

Andere mochten auch (20)

Tools for Metaspace
Tools for MetaspaceTools for Metaspace
Tools for Metaspace
 
Java GC, Off-heap workshop
Java GC, Off-heap workshopJava GC, Off-heap workshop
Java GC, Off-heap workshop
 
The Java Memory Model
The Java Memory ModelThe Java Memory Model
The Java Memory Model
 
Java 8 Launch - MetaSpaces
Java 8 Launch - MetaSpacesJava 8 Launch - MetaSpaces
Java 8 Launch - MetaSpaces
 
ClassLoader Leaks
ClassLoader LeaksClassLoader Leaks
ClassLoader Leaks
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
Native Memory Tracking
Native Memory TrackingNative Memory Tracking
Native Memory Tracking
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gc
 
Java memory model
Java memory modelJava memory model
Java memory model
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
 
Java memory presentation
Java memory presentationJava memory presentation
Java memory presentation
 
Tuning Java for Big Data
Tuning Java for Big DataTuning Java for Big Data
Tuning Java for Big Data
 
On heap cache vs off-heap cache
On heap cache vs off-heap cacheOn heap cache vs off-heap cache
On heap cache vs off-heap cache
 
Next-Gen Business Transaction Configuration, Instrumentation, and Java Perfor...
Next-Gen Business Transaction Configuration, Instrumentation, and Java Perfor...Next-Gen Business Transaction Configuration, Instrumentation, and Java Perfor...
Next-Gen Business Transaction Configuration, Instrumentation, and Java Perfor...
 
App Dynamics
App DynamicsApp Dynamics
App Dynamics
 
End User Monitoring with AppDynamics - AppSphere16
End User Monitoring with AppDynamics - AppSphere16End User Monitoring with AppDynamics - AppSphere16
End User Monitoring with AppDynamics - AppSphere16
 
AppDynamics VS New Relic – The Complete Guide
AppDynamics VS New Relic – The Complete GuideAppDynamics VS New Relic – The Complete Guide
AppDynamics VS New Relic – The Complete Guide
 
What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?
 
Sms-Voting and Elections
Sms-Voting and ElectionsSms-Voting and Elections
Sms-Voting and Elections
 

Ähnlich wie Memory Management: What You Need to Know When Moving to Java 8

Ähnlich wie Memory Management: What You Need to Know When Moving to Java 8 (20)

Simple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvmSimple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvm
 
Simple tweaks to get the most out of your JVM
Simple tweaks to get the most out of your JVMSimple tweaks to get the most out of your JVM
Simple tweaks to get the most out of your JVM
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
 
Troubleshooting Hadoop: Distributed Debugging
Troubleshooting Hadoop: Distributed DebuggingTroubleshooting Hadoop: Distributed Debugging
Troubleshooting Hadoop: Distributed Debugging
 
Loom promises: be there!
Loom promises: be there!Loom promises: be there!
Loom promises: be there!
 
JITServerTalk JCON World 2023.pdf
JITServerTalk JCON World 2023.pdfJITServerTalk JCON World 2023.pdf
JITServerTalk JCON World 2023.pdf
 
Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
 
Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019
 
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
 
GDG Cloud Southlake #20:Stefano Doni: Kubernetes performance tuning dilemma: ...
GDG Cloud Southlake #20:Stefano Doni: Kubernetes performance tuning dilemma: ...GDG Cloud Southlake #20:Stefano Doni: Kubernetes performance tuning dilemma: ...
GDG Cloud Southlake #20:Stefano Doni: Kubernetes performance tuning dilemma: ...
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
YARN
YARNYARN
YARN
 
Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019
 
Troubleshooting Memory Problems in Java Applications
Troubleshooting Memory Problems in Java ApplicationsTroubleshooting Memory Problems in Java Applications
Troubleshooting Memory Problems in Java Applications
 
SSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJSSSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJS
 
JITServerTalk Nebraska 2023.pdf
JITServerTalk Nebraska 2023.pdfJITServerTalk Nebraska 2023.pdf
JITServerTalk Nebraska 2023.pdf
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
 
Java-light-speed NebraskaCode.pdf
Java-light-speed NebraskaCode.pdfJava-light-speed NebraskaCode.pdf
Java-light-speed NebraskaCode.pdf
 

Mehr von AppDynamics

Mehr von AppDynamics (20)

Good Migrations: APM Essentials For Cloud Success at AppD Global Tour London
Good Migrations: APM Essentials For Cloud Success at AppD Global Tour LondonGood Migrations: APM Essentials For Cloud Success at AppD Global Tour London
Good Migrations: APM Essentials For Cloud Success at AppD Global Tour London
 
Top Tips For AppD Adoption Success at AppD Global Tour London
Top Tips For AppD Adoption Success at AppD Global Tour LondonTop Tips For AppD Adoption Success at AppD Global Tour London
Top Tips For AppD Adoption Success at AppD Global Tour London
 
How To Create An AppD Centre of Excellence at AppD Global Tour London
How To Create An AppD Centre of Excellence at AppD Global Tour LondonHow To Create An AppD Centre of Excellence at AppD Global Tour London
How To Create An AppD Centre of Excellence at AppD Global Tour London
 
Ensure Every Customer Matters With End User Monitoring at AppD Global Tour Lo...
Ensure Every Customer Matters With End User Monitoring at AppD Global Tour Lo...Ensure Every Customer Matters With End User Monitoring at AppD Global Tour Lo...
Ensure Every Customer Matters With End User Monitoring at AppD Global Tour Lo...
 
Just Eat: DevOps at Scale at AppD Global Tour London
Just Eat: DevOps at Scale at AppD Global Tour LondonJust Eat: DevOps at Scale at AppD Global Tour London
Just Eat: DevOps at Scale at AppD Global Tour London
 
What’s Next For AppDynamics and Cisco? AppD Global Tour London
What’s Next For AppDynamics and Cisco? AppD Global Tour LondonWhat’s Next For AppDynamics and Cisco? AppD Global Tour London
What’s Next For AppDynamics and Cisco? AppD Global Tour London
 
Unlock The Power Of Real-Time Performance Data With Business iQ - AppD Global...
Unlock The Power Of Real-Time Performance Data With Business iQ - AppD Global...Unlock The Power Of Real-Time Performance Data With Business iQ - AppD Global...
Unlock The Power Of Real-Time Performance Data With Business iQ - AppD Global...
 
Overcoming Transformational Barriers with Ensono - AppD Global Tour London
Overcoming Transformational Barriers with Ensono - AppD Global Tour LondonOvercoming Transformational Barriers with Ensono - AppD Global Tour London
Overcoming Transformational Barriers with Ensono - AppD Global Tour London
 
Equinor: What does normal look like?
Equinor: What does normal look like? Equinor: What does normal look like?
Equinor: What does normal look like?
 
Unlock The Power Of Real-Time Performance Data With Business iQ - AppD Global...
Unlock The Power Of Real-Time Performance Data With Business iQ - AppD Global...Unlock The Power Of Real-Time Performance Data With Business iQ - AppD Global...
Unlock The Power Of Real-Time Performance Data With Business iQ - AppD Global...
 
Top Tips For AppD Adoption Success - AppD Global Tour Stockholm
Top Tips For AppD Adoption Success - AppD Global Tour StockholmTop Tips For AppD Adoption Success - AppD Global Tour Stockholm
Top Tips For AppD Adoption Success - AppD Global Tour Stockholm
 
What's next for AppD and Cisco? - AppD Global Tour
What's next for AppD and Cisco? - AppD Global TourWhat's next for AppD and Cisco? - AppD Global Tour
What's next for AppD and Cisco? - AppD Global Tour
 
Cisco and AppDynamics: Redefining Application Intelligence - AppD Summit Europe
Cisco and AppDynamics: Redefining Application Intelligence - AppD Summit EuropeCisco and AppDynamics: Redefining Application Intelligence - AppD Summit Europe
Cisco and AppDynamics: Redefining Application Intelligence - AppD Summit Europe
 
British Medical Journal: Refine Your Metrics For Digital Success - AppD Summi...
British Medical Journal: Refine Your Metrics For Digital Success - AppD Summi...British Medical Journal: Refine Your Metrics For Digital Success - AppD Summi...
British Medical Journal: Refine Your Metrics For Digital Success - AppD Summi...
 
Forrester Research: How To Organise Your Business For Digital Success - AppD ...
Forrester Research: How To Organise Your Business For Digital Success - AppD ...Forrester Research: How To Organise Your Business For Digital Success - AppD ...
Forrester Research: How To Organise Your Business For Digital Success - AppD ...
 
Mastering APM With End User Monitoring - AppD Summit Europe
Mastering APM With End User Monitoring - AppD Summit EuropeMastering APM With End User Monitoring - AppD Summit Europe
Mastering APM With End User Monitoring - AppD Summit Europe
 
Become an AppDynamics Dashboard Rockstar - AppD Summit Europe
Become an AppDynamics Dashboard Rockstar - AppD Summit EuropeBecome an AppDynamics Dashboard Rockstar - AppD Summit Europe
Become an AppDynamics Dashboard Rockstar - AppD Summit Europe
 
Business iQ: What It Is and How to Start - AppD Summit Europe
Business iQ: What It Is and How to Start - AppD Summit EuropeBusiness iQ: What It Is and How to Start - AppD Summit Europe
Business iQ: What It Is and How to Start - AppD Summit Europe
 
Containers: Give Me The Facts, Not The Hype - AppD Summit Europe
Containers: Give Me The Facts, Not The Hype - AppD Summit EuropeContainers: Give Me The Facts, Not The Hype - AppD Summit Europe
Containers: Give Me The Facts, Not The Hype - AppD Summit Europe
 
Automation: The Good, The Bad and The Ugly with DevOpsGuys - AppD Summit Europe
Automation: The Good, The Bad and The Ugly with DevOpsGuys - AppD Summit EuropeAutomation: The Good, The Bad and The Ugly with DevOpsGuys - AppD Summit Europe
Automation: The Good, The Bad and The Ugly with DevOpsGuys - AppD Summit Europe
 

Kürzlich hochgeladen

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Kürzlich hochgeladen (20)

%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 

Memory Management: What You Need to Know When Moving to Java 8

  • 1. Memory Management What You Need To Know When Moving to Java 8 Todd Rader, Architect / Sales Engineer AppDynamics
  • 2. Market Leadership 175% Bookings Growth 2013 1000+ Customers OUR PLATFORM Website download Rapid Time to Value Low cost of ownership $ Enterprise adoption Scalable - largest APM deployments On-Premise, SaaS, Hybrid No professional Services 84 Net Promoter Score OUR APPDYNAMICS Copyright © 2014 AppDynamics. All rights reserved. 2
  • 3. Agenda • Memory Basics • …with a dive into metaspace • Fun With Garbage Collectors • GC bake-off • Summary/Conclusions • Q&A Copyright © 2014 AppDynamics. All rights reserved. 3
  • 4. Memory Basics: Types of Memory STACK • Each thread has its own call stack • Adjust with -Xss • 64-bit JVMs need more stack size (8-byte references) • Default stack size: ???? Java7, jdk1.7.0_51, 64-bit on MacOS 10.9.6 • Call depth before StackOverflowError: 10,827 (consistently) Java8, jdk1.8.0_05, 64-bit on MacOS 10.9.6 • Call depth before StackOverflowError: 20,000-ish (huh?) Copyright © 2014 AppDynamics. All rights reserved. 4
  • 5. Stack (cont’d) FUN WITH NUMBERS…. • With Java8 default stack size, call depth = 20,000-ish • Using –Xss1024k, same result (SO: default –Xss=1024k) • Using –XX:ThreadStackSize=1024, same result (- XX:ThreadStackSize is another way of expressing –Xss) Okay, but… • -Xss512k result: 9000-ish • Not quite linear! Need more memory space? Use a smaller –Xss value! • 200 threads * 512kb/thread = 100 MB saved! • What is your true stack size requirement? Copyright © 2014 AppDynamics. All rights reserved. 5
  • 6. Memory Basics: Types of Memory (cont’d) HEAP • Eden/New vs. Survivor vs. Old/Tenured • “Ideal Object Death Rate” • Eden >> Old >> Survivor Copyright © 2014 AppDynamics. All rights reserved. 6
  • 7. Heap (cont’d) HEAP • What is your object survival demography? • Caching! • Find out with: • -XX:+PrintGCDetails • -XX:+PrintTenuringDistribution • -XX:+PrintGCTimestamps • Adjust with: • -XX:NewRatio=n – Example: NewRatio=2  (oldGenSize) = 2 * (newGenSize) • -XX:NewSize=n (minimum) • -XX:MaxNewSize=n • -XX:MinFreeHeapRatio=n • -XX:MaxFreeHeapRatio=n Copyright © 2014 AppDynamics. All rights reserved. 7
  • 8. Heap: Java 6 HotSpot Copyright © 2014 AppDynamics. All rights reserved. 8
  • 9. Memory Basics: Types of Memory (cont’d) META • PermGen in Java 6 • PermGen (sort of) in Java 7 • Metaspace in Java 8 while (true) { int length = rnd.nextInt(100); StringBuilder builder = new StringBuilder(); String chars = "abcdefghijklmnopqrstuvwxyz"; for (int i = 0; i < length; i++) { builder.append(chars.charAt(rnd.nextInt(chars.length()))); } interned.add(builder.toString().intern()); } What happens when this code is run? Copyright © 2014 AppDynamics. All rights reserved. 9
  • 10. Running the code… JAVA 6 Exception in thread "main" java.lang.OutOfMemoryError: PermGen space • …in about 8 seconds! JAVA 7 Exception in thread "main" java.lang.OutOfMemoryError: Java heap space • …and it takes a long time to happen! JAVA 8 • Similar result as with Java 7 Copyright © 2014 AppDynamics. All rights reserved. 10
  • 11. What happened??? JAVA 6 PermGen contains: • Class meta data • Interned strings JAVA 7 • Interned strings moved to Metaspace JAVA 8 • Class meta data also moved to Metaspace Copyright © 2014 AppDynamics. All rights reserved. 11
  • 12. Metaspace REPLACEMENT FOR PERMGEN • NOT JVM memory – native memory! • BEA/Oracle JRockit • IBM JVM SOME NEW STARTUP FLAGS • -XX:MetaSpaceSize=n (initial size) • -XX:MaxMetaSpaceSize=n • -XX:MaxMetaspaceExpansion=n • -XX:MaxMetaspaceFreeRatio=n • No default values for size! Max metaspace size is unlimited :-0 • Say goodbye to PermGen problems……right? Right? Copyright © 2014 AppDynamics. All rights reserved. 12
  • 13. More Metaspace OBSOLETES SOME OLD STARTUP FLAGS • All of the “-XX:*Perm*” flags NEW MEMORY POOL OBJECTS • No more matching on “Perm” for pool name Copyright © 2014 AppDynamics. All rights reserved. 13
  • 14. What does this mean? NO MORE OOM/PERMGEN • But metaspace errors don’t go away  • Monitor metaspace, not PermGen • Use –XX:MaxMetaSpaceSize? • No  you will never run out of metaspace • …but your use of native memory can grow unbounded! • Yes  you merely replace “OutOfMemory: PermGen space” with “OutOfMemory: Metaspace” MONITOR METASPACE • Apps that leak metadata will still leak metadata • Gobbling up metaspace affects the entire system, not just the JVM • Remember: native memory! Copyright © 2014 AppDynamics. All rights reserved. 14
  • 15. Monitoring Metaspace COMMERCIAL SOLUTIONS • Expect (demand!) metaspace monitoring support to go along with Java 8 support JAVA MANAGEMENT BEANS • Update any querying of MBeans to search for Metaspace memory pool instead of PermGen pools. JVISUALVM • Metaspace monitoring supported • …at least in the jvisualvm that is bundled with Jdk1.8.0_05 on MacOS! Copyright © 2014 AppDynamics. All rights reserved. 15
  • 16. Memory Basics: Types of Memory (cont’d) DIRECT • sun.misc.Unsafe • Used by the JDK (nio classes, for example) • Out of the scope of this talk! Copyright © 2014 AppDynamics. All rights reserved. 16
  • 17. Let’s talk garbage… PARALLEL GC • Default on Java 7, Java 8 • ParNewGC is the default on Java 6 • Does parallel compaction in Java 6 and 7 • -XX:+UseParallelOldGC option in Java 5 CONCURRENT MARK AND SWEEP GC • NOT compacting! • Can be prone to fragmentation of old gen •  very bad full GCs result G1GC • Only use after jdk1.7.0_u4! • “Experimental” in previous releases Copyright © 2014 AppDynamics. All rights reserved. 17
  • 18. The GC Bake-off GC KILLER PROGRAM • Allocates lots of java.lang.Objects • Allocates fewer long Strings • Keeps objects around for varying lengths of times • Checks heap memory availability • When low, thousands of memory references are let go of • No GC tuning options used • 15-minute runs (killed with Ctrl-C) • Java 7 vs. Java 8 Copyright © 2014 AppDynamics. All rights reserved. 18
  • 19. Java 7, Parallel GC Copyright © 2014 AppDynamics. All rights reserved. 19
  • 20. Java 7, Parallel GC HIGHLIGHTS • No “-XX” option to enable (default) • Heap usage varied between 1500-2750 MB • Reasonable time spent in GC (1.6 seconds/minute) • No major collections Copyright © 2014 AppDynamics. All rights reserved. 20
  • 21. Java 7, ConcMarkSweepGC Copyright © 2014 AppDynamics. All rights reserved. 21
  • 22. Java 7, ConcMarkSweepGC HIGHLIGHTS • Enabled with –XX:+UseConcMarkSweepGC • Heap usage held steady around 2000 MB • Huge amount of time spent in GC (24 seconds/minute!) • No major collections Copyright © 2014 AppDynamics. All rights reserved. 22
  • 23. Java 7, G1GC Copyright © 2014 AppDynamics. All rights reserved. 23
  • 24. Java 7, G1GC HIGHLIGHTS • Enabled with –XX:+UseG1GC • Heap usage varied between 750-2800 MB • Very reasonable time spent in GC (0.6 seconds/minute) • No major collections Copyright © 2014 AppDynamics. All rights reserved. 24
  • 25. The winner for Java 7 G1! • Less time spent in GC • Heap usage max barely more than max using Parallel • CMS max heap usage was only 2000 • CMS min was also near 2000 (very steady) • Heap usage min best of all three • No major collections • BUT: • Remember, no GC tuning parameters were used • DO NOT USE G1GC before jdk1.7.0_04 • “Experimental” in prior releases Copyright © 2014 AppDynamics. All rights reserved. 25
  • 26. Java 8, Parallel GC Copyright © 2014 AppDynamics. All rights reserved. 26
  • 27. Java 8, Parallel GC HIGHLIGHTS • Incrementally worse than ParallelGC on Java 7 • Higher max heap (2950 vs. 2750) • Higher min heap (1700MB vs. 1500MB) • Roughly the same GC time (1.6 seconds/minute) • No major collections Copyright © 2014 AppDynamics. All rights reserved. 27
  • 28. Java 8, ConcMarkSweepGC Copyright © 2014 AppDynamics. All rights reserved. 28
  • 29. Java 8, ConcMarkSweepGC HIGHLIGHTS • Just……lousy • HUGE amount of initial time spent in gc • 55 seconds/minute! • Heap usage steadily declined • From 3000MB to 2000MB • With all that time spent, you’d think a major collection would be avoided • You’d be wrong  • The only run with a major collection Copyright © 2014 AppDynamics. All rights reserved. 29
  • 30. Java 8, G1GC Copyright © 2014 AppDynamics. All rights reserved. 30
  • 31. Java 8, G1GC HIGHLIGHTS • Incrementally worse than G1/Java 7 • Heap usage max 2850MB vs. 2800MB • GC time .8 seconds/minute vs. .6 seconds/minute • No major collections Copyright © 2014 AppDynamics. All rights reserved. 31
  • 32. The winner for Java 8, and overall G1 AGAIN! • CMS not even close • G1 on Java 7 overall winner • Caveats: • No GC tuning parameters used • Heap-only: very little metadata memory used • MacOS 10.9.4 (Maverick’s) • 2.8 GHz Intel Core i7 processor • 16 GB 1600 MHz memory • Java 7: jdk 1.7.0_51 for MacOS • Java 8: jdk 1.8.0_05 for MacOS Copyright © 2014 AppDynamics. All rights reserved. 32
  • 33. GC Tuning OUT OF SCOPE  • 600+ “-XX:” options • 83 for CMS in Java 7 • 82 for CMS in Java 8 • No love for CMSTriggerPermRatio! • 24 for G1 in Java 7 and 8 • Too many to cover! Copyright © 2014 AppDynamics. All rights reserved. 33
  • 34. Summary • Know your object demography • Monitor your metaspace • Interned strings • Class metadata • Research the best GC • Watch out for outdated information • G1GC tests before jdk1.7.0_04 • Re-think CMS GC? • Un-tuned CMS results far worse Copyright © 2014 AppDynamics. All rights reserved. 34

Hinweis der Redaktion

  1. SLIDE3: Why AppDynamics? establish credibility through 3rd party validation Commitment to customer success Business and customer growth Describe our GTM model – ease of deployment, Enterprise grade, proven in the most demanding environments and high impact, fast   . 
  2. Quiz: what is the default Java stack size?
  3. Quiz: what is the default Java stack size? Point of slide: If you’ve ever had to manage stack size, don’t expect Java 8 behavior to be the same as Java 7 Note that you can’t directly get the stack trace depth, only the size.
  4. Any questions on stack memory?
  5. Question: how many modern apps have this object death rate? Question: what common technique completely changes this picture?
  6. Question: how many modern apps have this object death rate?
  7. Blast from the past – Java 6 HotSpot Summary: heap is basically the same in Java 6/7/8, but GC options change Any questions about heap?
  8. Ask if anybody is surprised by this, can explain this
  9. Mention performance impact if interned strings were a big source of PermGen use in Java 6 Ask about the logo
  10. Push on the “no max size” theme. What would happen if a program that leaked class metadata permgen in Java 6 were put onto Java 8? Can get old behavior with MaxMetaSpaceSize
  11. Story about how PermGen can affect monitoring tools Retransform -> app holds onto class/meta references (reflection object caching)
  12. A PermGen problem will be less frequent but more severe if it moves to being a metaspace problem
  13. Ask for any questions on memory before we switch to garbage collection
  14. Why 15-minute periods? – practical: time needed to tune program for proper rate of allocation plus doing all the runs for comparison.
  15. Tune the program:
  16. What are the group’s experiences? Any questions on Java 7 results, before we move onto Java 8?
  17. What do you think CMS looks like on Java 8 with no tuning options?
  18. Monitoring memory and JVM stats is only a tiny part of what AppD does