SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
JVM Garbage
Collection Tuning
Heejong Lee
Reference: JVM Garbage Collection Tuning (http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html)
Pause-the-world garbage collector’s performance loss in parallelized systems
Lifetime distribution of objects
Efficient collection is made possible by focusing on the fact that
a majority of objects die young
Lifetime of objects
Eden
Survivor 1
Survivor 2
Tenured
• The percentage of total time
not spent in garbage
collection
• Includes time spent in
allocation
Two Primary Measures of Garbage Collection
Performance
• Times when an application
appears unresponsive
because garbage collection is
occurring
Throughput Pauses
• The working set of one
process, measured in pages
and cache lines
• May dictate scalability
Two Alternative Measures of Garbage Collection
Performance
• The time between when an
object becomes dead and
when the memory becomes
available
Footprint Promptness
Trade-off between Measures of Garbage Collection
Performance
• A very large young generation space may maximize throughput,
but does so at the expense of footprint, promptness and pause
times
• A small young generation space can minimize young generation
pauses at the expense of throughput
• Metrics particular to the
application
• ex) client load generator for
web servers, pmap for
daemons
Measurement of Garbage Collection Performance
• The diagnostic output of
virtual machine itself
Throughput, Footprint Pauses
Measurement of Garbage Collection Performance
• `-verbose:gc` causes information about the heap and garbage
collection
Pauses
[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]
Measurement of Garbage Collection Performance
• `-verbose:gc` causes information about the heap and garbage
collection
Pauses
[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]
minor collection (young generation collection)
Measurement of Garbage Collection Performance
• `-verbose:gc` causes information about the heap and garbage
collection
Pauses
[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]
major collection (all generation collection)
Measurement of Garbage Collection Performance
• `-verbose:gc` causes information about the heap and garbage
collection
Pauses
[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]
the combined size of live objects before and after gc
Measurement of Garbage Collection Performance
• `-verbose:gc` causes information about the heap and garbage
collection
Pauses
[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]
the amount of space usable for java objects without requesting more memory from the OS
(except permanent generation and one of the survivor spaces)
Measurement of Garbage Collection Performance
• `-verbose:gc` causes information about the heap and garbage
collection
Pauses
[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]
the time taken to perform the collection
Measurement of Garbage Collection Performance
• `-XX:+PrintGCDetails` causes additional information about the
heap and garbage collection
Pauses
[GC [DefNew: 64575K->959K(64576K), 0.0457646 secs] 196016K->133633K(261184K), 0.0459067 secs]
the log from young generation
Measurement of Garbage Collection Performance
• `-XX:+PrintGCDetails` causes additional information about the
heap and garbage collection
Pauses
[GC [DefNew: 64575K->959K(64576K), 0.0457646 secs] 196016K->133633K(261184K), 0.0459067 secs]
the log from entire heap
Measurement of Garbage Collection Performance
• `-XX:+PrintGCTimeStamps` will add a time stamp at the start of
each collection
Pauses
111.042: [GC 111.042: [DefNew: 8128K->8128K(8128K), 0.0000505 secs]111.042: [Tenured: 18154K-
>2311K(24576K), 0.1290354 secs] 26282K->2311K(32704K), 0.1293306 secs]
The Difference between Memory Size Ratios
Sizing the Generations
Total Heap
• `-XX:MinHeapFreeRatio=` : the generation will be expanded to
maintain the given ratio (in percent) of free space
• `-XX:MaxHeapFreeRatio=` : the generation will be contracted to
maintain the given ratio (in percent) of free space
• `-Xms` : lower bound of heap size
• `-Xmx` : upper bound of heap size
Sizing the Generations
The Rules of Adjusting Total Heap
• Try granting as much memory as possible unless you have
problems with pauses
• Setting `-Xms` and `-Xmx` to the same value increases
predictability by removing the most important sizing decision,
however the virtual machine cannot compensate a poor choice
Sizing the Generations
Young Generation
• `-XX:NewRatio=` : the ratio between young and tenured
generations. For example, 3 means the combined size of the eden
and survivor spaces will be one fourth of the total heap size
• `-XX:NewSize=` : lower bound of the young generation size
• `-XX:MaxNewSize=` : upper bound of the young generation size
Sizing the Generations
Young Generation
• The bigger the young generation, the less often minor collection
occur
• However, (because the total heap size is bounded) which will
increase the frequency of major collection
Sizing the Generations
Young Generation (Survivor Space)
• `-XX:SurvivorRatio=` : the ratio between eden and survivor space.
For example, 6 means each survivor space will be one sixth the
size of eden
• `-XX:+PrintTenuringDistribution` : show tenuring threshold and the
ages of objects in the young generation
Sizing the Generations
Young Generation (Survivor Space)
• If survivor spaces are too small, copying collection overflows
directly into the tenured generation
• The threshold controlled the number of times an object can be
copied before it is tenured is chosen to keep the survivor half full
Garbage Collectors
Serial Collector
• Uses single thread
• Relatively efficient since there is no communication overhead
between threads
• `-XX:+UseSerialGC`
Parallel Collector
(Throughput Collector)
• Performs minor collections in parallel (`-XX:+UseParallelGC`)
• Performs major and minor collections in parallel (`-XX:
+UseParallelOldGC`, available since 5u6, default since 7u4)
• Intended for applications with medium- to large-sized data
sets that are run on multi-threaded hardware
Concurrent Collector
• Performs most of its work concurrently
• Intended for applications with medium- to large-sized data
sets for which response time is more important than overall
throughput
• `-XX:+UseConcMarkSweepGC`
Selecting a Collector
Application has a small data set (up to
100MB)
• `-XX:+UseSerialGC`
Application will be run on a single
processor & no pause time requirement
• Let VM select the collector
• Or, `-XX:+UseSerialGC`
Peak application performance is the first
priority & no pause time requirement
• Let VM select the collector
• Or, `-XX:+UseParallelGC`, `-XX:+UseParallelOldGC`
Response time is more important than
overall throughput & pause time must be
kept short
• `-XX:+UseConcMarkSweepGC`
Parallel Collector
• On default, uses N garbage collector threads on a machine with N
processors
• One processor (serial collector > parallel collector)
• Two processors (serial collector < parallel collector)
• Three or more processors ( serial collector <<< parallel collector)
• `-XX:ParallelGCThreads=` controls the number of garbage
collector threads
Parallel Collector
• On default, uses N garbage collector threads on a machine with N
processors
• One processor (serial collector > parallel collector)
• Two processors (serial collector < parallel collector)
• Three or more processors ( serial collector <<< parallel collector)
• `-XX:ParallelGCThreads=` controls the number of garbage
collector threads
Ergonomics
• The parallel collector is selected by default on server-class machine
(since J2SE5)
• Automatic tuning is available by three goals (order by priority):
• Maximum garbage collection pause time (-XX:MaxGCPauseMillis=)
• Throughput (-XX:GCTimeRatio=)

default value is 99, resulting in a goal of 1% of the time in GC
• Footprint (-Xmx)
Default Heap Size
• Initial heap size : memory / DefaultInitialRAMFraction

(default: memory / 64)
• Maximum heap size : MIN(memory / DefaultMaxRAMFraction, 1GB)

(default: MIN(memory / 4), 1GB)
OutOfMemoryError
• If more than 98% of the total time is spent in garbage collection and
less than 2% of the heap is recovered
• Can be disabled by `-XX:-UseGCOverheadLimit`
Concurrent Collector
• Reduces the time required for major collection (low pause time): suitable
for applications which have a relatively large set of long-lived data and
run on machines with two or more processors
• Only two short pause during each major collection (mark and remark)
• Most of the work in the major collection (tracing of live objects, sweeping
of unreachable objects) is done concurrently with the application
• Minor collections are done in a manner similar to the parallel collector
(the application threads are stopped during the collection)
• Concurrent mode failure when GC fails to completing the collection
before either the tenured and permanent generation becomes full
OutOfMemoryError (of Concurrent Collection)
• If more than 98% of the total time is spent in garbage collection and
less than 2% of the heap is recovered
• Can be disabled by `-XX:-UseGCOverheadLimit`
• Only collections performed while the application is stopped count
toward excessive GC time (typically due to a concurrent mode failure
or an explicit call to System.gc())
Floating Garbage (of Concurrent Collection)
• Objects that became unreachable by the time collection finishes and
will be collected during the next collection cycle
• A rough rule of thumb: try increasing the size of the tenured generation
by 20% to account for the floating garbage
Concurrent Phases
Mark
Tracing reachable
object graph
Remark
Sweeping
unreachable objects Wait
Pause Consume CPU resource Pause Consume CPU resource
Use minimum
resource
Starting Concurrent Collection Cycle
• The concurrent collector maintains estimate time remaining before the
tenured generation will be exhausted and of the time needed for a
concurrent collection cycle
• A concurrent collection cycle will be started based on these dynamic
estimates
• Will also start if the occupancy of the tenured generation exceeds an
initiating occupancy. This percentage value can be adjusted with the
option `-XX:CMSInitiatingOccupancyFraction=`
Incremental Mode
• Breaking up the concurrent phases into short burst of activity, which
are scheduled to occur mid-way between minor pauses
• Especially useful when applications that need the low pause times are
run on machines with small numbers of processors (e.g., 1 or 2)
Incremental Mode
• `-XX:+CMSIncrementalMode`: enables incremental mode. must also
be enabled with `-XX:+UseConcMarkSweepGC`
• `-XX:+CMSIncrementalPacing`: enables automatic pacing. The
incremental mode duty cycle is automatically adjusted based on
statistics collected while the JVM is running
• `-XX:CMSIncrementalDutyCycle=`: the percentage of time between
minor collections that the concurrent collector is allowed to run. Just
initial value when CMSIncrementalPacing is enabled
Recommended Option for Incremental Mode
-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode 
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps
-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode 
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps 
-XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0
-XX:CMSIncrementalDutyCycle=10
Java 6
Java 5
Explicit Garbage Collection
• `-XX:+DisableExplicitGC` causes the VM to ignore calls to System.gc()

Mais conteúdo relacionado

Mais procurados

Fight with Metaspace OOM
Fight with Metaspace OOMFight with Metaspace OOM
Fight with Metaspace OOMLeon Chen
 
Tuning Java GC to resolve performance issues
Tuning Java GC to resolve performance issuesTuning Java GC to resolve performance issues
Tuning Java GC to resolve performance issuesSergey Podolsky
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage CollectionAzul Systems Inc.
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvmPrem Kuppumani
 
JVM and Garbage Collection Tuning
JVM and Garbage Collection TuningJVM and Garbage Collection Tuning
JVM and Garbage Collection TuningKai Koenig
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展Leon Chen
 
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 cachergrebski
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItAzul Systems Inc.
 
(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag Session(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag SessionJens Hadlich
 
Debugging Your Production JVM
Debugging Your Production JVMDebugging Your Production JVM
Debugging Your Production JVMkensipe
 
JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011Kris Mok
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuningJerry Kurian
 
Pick diamonds from garbage
Pick diamonds from garbagePick diamonds from garbage
Pick diamonds from garbageTier1 App
 
ELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log systemELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log systemAvleen Vig
 
Tuning Java for Big Data
Tuning Java for Big DataTuning Java for Big Data
Tuning Java for Big DataScott Seighman
 
Garbage First and you
Garbage First and youGarbage First and you
Garbage First and youKai Koenig
 
Storing Cassandra Metrics
Storing Cassandra MetricsStoring Cassandra Metrics
Storing Cassandra MetricsChris Lohfink
 
Facebook C++网络库Wangle调研
Facebook C++网络库Wangle调研Facebook C++网络库Wangle调研
Facebook C++网络库Wangle调研vorfeed chen
 

Mais procurados (20)

Fight with Metaspace OOM
Fight with Metaspace OOMFight with Metaspace OOM
Fight with Metaspace OOM
 
Tuning Java GC to resolve performance issues
Tuning Java GC to resolve performance issuesTuning Java GC to resolve performance issues
Tuning Java GC to resolve performance issues
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
 
Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvm
 
JVM and Garbage Collection Tuning
JVM and Garbage Collection TuningJVM and Garbage Collection Tuning
JVM and Garbage Collection Tuning
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展
 
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
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About It
 
(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag Session(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag Session
 
Debugging Your Production JVM
Debugging Your Production JVMDebugging Your Production JVM
Debugging Your Production JVM
 
JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Pick diamonds from garbage
Pick diamonds from garbagePick diamonds from garbage
Pick diamonds from garbage
 
ELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log systemELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log system
 
Tuning Java for Big Data
Tuning Java for Big DataTuning Java for Big Data
Tuning Java for Big Data
 
Garbage First and you
Garbage First and youGarbage First and you
Garbage First and you
 
无锁编程
无锁编程无锁编程
无锁编程
 
Storing Cassandra Metrics
Storing Cassandra MetricsStoring Cassandra Metrics
Storing Cassandra Metrics
 
Facebook C++网络库Wangle调研
Facebook C++网络库Wangle调研Facebook C++网络库Wangle调研
Facebook C++网络库Wangle调研
 

Destaque

The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in DjangoRami Sayar
 
Websockets: Pushing the web forward
Websockets: Pushing the web forwardWebsockets: Pushing the web forward
Websockets: Pushing the web forwardMark Roden
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...Frank Munz
 
Maximize information exchange in your enterprise with AMQP
Maximize information exchange in your enterprise with AMQPMaximize information exchange in your enterprise with AMQP
Maximize information exchange in your enterprise with AMQPKenneth Peeples
 
HTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive ListHTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive ListMainstreethost
 
HTTP/2 Changes Everything
HTTP/2 Changes EverythingHTTP/2 Changes Everything
HTTP/2 Changes EverythingLori MacVittie
 
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media Server
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media ServerAWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media Server
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media ServerAmazon Web Services
 
HTML5 WebSockets in Python/Django
HTML5 WebSockets in Python/DjangoHTML5 WebSockets in Python/Django
HTML5 WebSockets in Python/DjangoTony Abou-Assaleh
 

Destaque (10)

The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in Django
 
Websockets: Pushing the web forward
Websockets: Pushing the web forwardWebsockets: Pushing the web forward
Websockets: Pushing the web forward
 
Reducing load with RabbitMQ
Reducing load with RabbitMQReducing load with RabbitMQ
Reducing load with RabbitMQ
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
 
Maximize information exchange in your enterprise with AMQP
Maximize information exchange in your enterprise with AMQPMaximize information exchange in your enterprise with AMQP
Maximize information exchange in your enterprise with AMQP
 
HTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive ListHTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive List
 
HTTP/2 Changes Everything
HTTP/2 Changes EverythingHTTP/2 Changes Everything
HTTP/2 Changes Everything
 
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media Server
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media ServerAWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media Server
AWS Webcast - Live Streaming using Amazon CloudFront and Wowza Media Server
 
HTML5 WebSockets in Python/Django
HTML5 WebSockets in Python/DjangoHTML5 WebSockets in Python/Django
HTML5 WebSockets in Python/Django
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 

Semelhante a JVM Garbage Collection Tuning

What you need to know about GC
What you need to know about GCWhat you need to know about GC
What you need to know about GCKelum Senanayake
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionHaribabu Nandyal Padmanaban
 
Java gc and JVM optimization
Java gc  and JVM optimizationJava gc  and JVM optimization
Java gc and JVM optimizationRajan Jethva
 
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Anna Shymchenko
 
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Java Garbage Collectors – Moving to Java7 Garbage First (G1) CollectorJava Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Java Garbage Collectors – Moving to Java7 Garbage First (G1) CollectorGurpreet Sachdeva
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020Jelastic Multi-Cloud PaaS
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Prashanth Kumar
 
.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4aminmesbahi
 
G1 collector and tuning and Cassandra
G1 collector and tuning and CassandraG1 collector and tuning and Cassandra
G1 collector and tuning and CassandraChris Lohfink
 
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory UsageChoosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory UsageJelastic Multi-Cloud PaaS
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUGJorge Morales
 
Garbage collection
Garbage collectionGarbage collection
Garbage collectionMudit Gupta
 
A Beginner’s Guide to Kafka Performance in Cloud Environments with Steffen Ha...
A Beginner’s Guide to Kafka Performance in Cloud Environments with Steffen Ha...A Beginner’s Guide to Kafka Performance in Cloud Environments with Steffen Ha...
A Beginner’s Guide to Kafka Performance in Cloud Environments with Steffen Ha...HostedbyConfluent
 
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...Jelastic Multi-Cloud PaaS
 

Semelhante a JVM Garbage Collection Tuning (20)

What you need to know about GC
What you need to know about GCWhat you need to know about GC
What you need to know about GC
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
 
Java gc and JVM optimization
Java gc  and JVM optimizationJava gc  and JVM optimization
Java gc and JVM optimization
 
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
jvm.pptx
jvm.pptxjvm.pptx
jvm.pptx
 
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Java Garbage Collectors – Moving to Java7 Garbage First (G1) CollectorJava Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
 
.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4
 
Alfresco tuning part2
Alfresco tuning part2Alfresco tuning part2
Alfresco tuning part2
 
ZGC-SnowOne.pdf
ZGC-SnowOne.pdfZGC-SnowOne.pdf
ZGC-SnowOne.pdf
 
G1 collector and tuning and Cassandra
G1 collector and tuning and CassandraG1 collector and tuning and Cassandra
G1 collector and tuning and Cassandra
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
 
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory UsageChoosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUG
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
 
Jvm Architecture
Jvm ArchitectureJvm Architecture
Jvm Architecture
 
A Beginner’s Guide to Kafka Performance in Cloud Environments with Steffen Ha...
A Beginner’s Guide to Kafka Performance in Cloud Environments with Steffen Ha...A Beginner’s Guide to Kafka Performance in Cloud Environments with Steffen Ha...
A Beginner’s Guide to Kafka Performance in Cloud Environments with Steffen Ha...
 
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
 

Último

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
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 GoalsJhone kinadey
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 

Último (20)

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
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
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

JVM Garbage Collection Tuning

  • 1. JVM Garbage Collection Tuning Heejong Lee Reference: JVM Garbage Collection Tuning (http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html)
  • 2. Pause-the-world garbage collector’s performance loss in parallelized systems
  • 3. Lifetime distribution of objects Efficient collection is made possible by focusing on the fact that a majority of objects die young
  • 4. Lifetime of objects Eden Survivor 1 Survivor 2 Tenured
  • 5. • The percentage of total time not spent in garbage collection • Includes time spent in allocation Two Primary Measures of Garbage Collection Performance • Times when an application appears unresponsive because garbage collection is occurring Throughput Pauses
  • 6. • The working set of one process, measured in pages and cache lines • May dictate scalability Two Alternative Measures of Garbage Collection Performance • The time between when an object becomes dead and when the memory becomes available Footprint Promptness
  • 7. Trade-off between Measures of Garbage Collection Performance • A very large young generation space may maximize throughput, but does so at the expense of footprint, promptness and pause times • A small young generation space can minimize young generation pauses at the expense of throughput
  • 8. • Metrics particular to the application • ex) client load generator for web servers, pmap for daemons Measurement of Garbage Collection Performance • The diagnostic output of virtual machine itself Throughput, Footprint Pauses
  • 9. Measurement of Garbage Collection Performance • `-verbose:gc` causes information about the heap and garbage collection Pauses [GC 325407K->83000K(776768K), 0.2300771 secs] [GC 325816K->83372K(776768K), 0.2454258 secs] [Full GC 267628K->83769K(776768K), 1.8479984 secs]
  • 10. Measurement of Garbage Collection Performance • `-verbose:gc` causes information about the heap and garbage collection Pauses [GC 325407K->83000K(776768K), 0.2300771 secs] [GC 325816K->83372K(776768K), 0.2454258 secs] [Full GC 267628K->83769K(776768K), 1.8479984 secs] minor collection (young generation collection)
  • 11. Measurement of Garbage Collection Performance • `-verbose:gc` causes information about the heap and garbage collection Pauses [GC 325407K->83000K(776768K), 0.2300771 secs] [GC 325816K->83372K(776768K), 0.2454258 secs] [Full GC 267628K->83769K(776768K), 1.8479984 secs] major collection (all generation collection)
  • 12. Measurement of Garbage Collection Performance • `-verbose:gc` causes information about the heap and garbage collection Pauses [GC 325407K->83000K(776768K), 0.2300771 secs] [GC 325816K->83372K(776768K), 0.2454258 secs] [Full GC 267628K->83769K(776768K), 1.8479984 secs] the combined size of live objects before and after gc
  • 13. Measurement of Garbage Collection Performance • `-verbose:gc` causes information about the heap and garbage collection Pauses [GC 325407K->83000K(776768K), 0.2300771 secs] [GC 325816K->83372K(776768K), 0.2454258 secs] [Full GC 267628K->83769K(776768K), 1.8479984 secs] the amount of space usable for java objects without requesting more memory from the OS (except permanent generation and one of the survivor spaces)
  • 14. Measurement of Garbage Collection Performance • `-verbose:gc` causes information about the heap and garbage collection Pauses [GC 325407K->83000K(776768K), 0.2300771 secs] [GC 325816K->83372K(776768K), 0.2454258 secs] [Full GC 267628K->83769K(776768K), 1.8479984 secs] the time taken to perform the collection
  • 15. Measurement of Garbage Collection Performance • `-XX:+PrintGCDetails` causes additional information about the heap and garbage collection Pauses [GC [DefNew: 64575K->959K(64576K), 0.0457646 secs] 196016K->133633K(261184K), 0.0459067 secs] the log from young generation
  • 16. Measurement of Garbage Collection Performance • `-XX:+PrintGCDetails` causes additional information about the heap and garbage collection Pauses [GC [DefNew: 64575K->959K(64576K), 0.0457646 secs] 196016K->133633K(261184K), 0.0459067 secs] the log from entire heap
  • 17. Measurement of Garbage Collection Performance • `-XX:+PrintGCTimeStamps` will add a time stamp at the start of each collection Pauses 111.042: [GC 111.042: [DefNew: 8128K->8128K(8128K), 0.0000505 secs]111.042: [Tenured: 18154K- >2311K(24576K), 0.1290354 secs] 26282K->2311K(32704K), 0.1293306 secs]
  • 18. The Difference between Memory Size Ratios
  • 19. Sizing the Generations Total Heap • `-XX:MinHeapFreeRatio=` : the generation will be expanded to maintain the given ratio (in percent) of free space • `-XX:MaxHeapFreeRatio=` : the generation will be contracted to maintain the given ratio (in percent) of free space • `-Xms` : lower bound of heap size • `-Xmx` : upper bound of heap size
  • 20. Sizing the Generations The Rules of Adjusting Total Heap • Try granting as much memory as possible unless you have problems with pauses • Setting `-Xms` and `-Xmx` to the same value increases predictability by removing the most important sizing decision, however the virtual machine cannot compensate a poor choice
  • 21. Sizing the Generations Young Generation • `-XX:NewRatio=` : the ratio between young and tenured generations. For example, 3 means the combined size of the eden and survivor spaces will be one fourth of the total heap size • `-XX:NewSize=` : lower bound of the young generation size • `-XX:MaxNewSize=` : upper bound of the young generation size
  • 22. Sizing the Generations Young Generation • The bigger the young generation, the less often minor collection occur • However, (because the total heap size is bounded) which will increase the frequency of major collection
  • 23. Sizing the Generations Young Generation (Survivor Space) • `-XX:SurvivorRatio=` : the ratio between eden and survivor space. For example, 6 means each survivor space will be one sixth the size of eden • `-XX:+PrintTenuringDistribution` : show tenuring threshold and the ages of objects in the young generation
  • 24. Sizing the Generations Young Generation (Survivor Space) • If survivor spaces are too small, copying collection overflows directly into the tenured generation • The threshold controlled the number of times an object can be copied before it is tenured is chosen to keep the survivor half full
  • 25. Garbage Collectors Serial Collector • Uses single thread • Relatively efficient since there is no communication overhead between threads • `-XX:+UseSerialGC` Parallel Collector (Throughput Collector) • Performs minor collections in parallel (`-XX:+UseParallelGC`) • Performs major and minor collections in parallel (`-XX: +UseParallelOldGC`, available since 5u6, default since 7u4) • Intended for applications with medium- to large-sized data sets that are run on multi-threaded hardware Concurrent Collector • Performs most of its work concurrently • Intended for applications with medium- to large-sized data sets for which response time is more important than overall throughput • `-XX:+UseConcMarkSweepGC`
  • 26. Selecting a Collector Application has a small data set (up to 100MB) • `-XX:+UseSerialGC` Application will be run on a single processor & no pause time requirement • Let VM select the collector • Or, `-XX:+UseSerialGC` Peak application performance is the first priority & no pause time requirement • Let VM select the collector • Or, `-XX:+UseParallelGC`, `-XX:+UseParallelOldGC` Response time is more important than overall throughput & pause time must be kept short • `-XX:+UseConcMarkSweepGC`
  • 27. Parallel Collector • On default, uses N garbage collector threads on a machine with N processors • One processor (serial collector > parallel collector) • Two processors (serial collector < parallel collector) • Three or more processors ( serial collector <<< parallel collector) • `-XX:ParallelGCThreads=` controls the number of garbage collector threads
  • 28. Parallel Collector • On default, uses N garbage collector threads on a machine with N processors • One processor (serial collector > parallel collector) • Two processors (serial collector < parallel collector) • Three or more processors ( serial collector <<< parallel collector) • `-XX:ParallelGCThreads=` controls the number of garbage collector threads
  • 29. Ergonomics • The parallel collector is selected by default on server-class machine (since J2SE5) • Automatic tuning is available by three goals (order by priority): • Maximum garbage collection pause time (-XX:MaxGCPauseMillis=) • Throughput (-XX:GCTimeRatio=)
 default value is 99, resulting in a goal of 1% of the time in GC • Footprint (-Xmx)
  • 30. Default Heap Size • Initial heap size : memory / DefaultInitialRAMFraction
 (default: memory / 64) • Maximum heap size : MIN(memory / DefaultMaxRAMFraction, 1GB)
 (default: MIN(memory / 4), 1GB)
  • 31. OutOfMemoryError • If more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered • Can be disabled by `-XX:-UseGCOverheadLimit`
  • 32. Concurrent Collector • Reduces the time required for major collection (low pause time): suitable for applications which have a relatively large set of long-lived data and run on machines with two or more processors • Only two short pause during each major collection (mark and remark) • Most of the work in the major collection (tracing of live objects, sweeping of unreachable objects) is done concurrently with the application • Minor collections are done in a manner similar to the parallel collector (the application threads are stopped during the collection) • Concurrent mode failure when GC fails to completing the collection before either the tenured and permanent generation becomes full
  • 33. OutOfMemoryError (of Concurrent Collection) • If more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered • Can be disabled by `-XX:-UseGCOverheadLimit` • Only collections performed while the application is stopped count toward excessive GC time (typically due to a concurrent mode failure or an explicit call to System.gc())
  • 34. Floating Garbage (of Concurrent Collection) • Objects that became unreachable by the time collection finishes and will be collected during the next collection cycle • A rough rule of thumb: try increasing the size of the tenured generation by 20% to account for the floating garbage
  • 35. Concurrent Phases Mark Tracing reachable object graph Remark Sweeping unreachable objects Wait Pause Consume CPU resource Pause Consume CPU resource Use minimum resource
  • 36. Starting Concurrent Collection Cycle • The concurrent collector maintains estimate time remaining before the tenured generation will be exhausted and of the time needed for a concurrent collection cycle • A concurrent collection cycle will be started based on these dynamic estimates • Will also start if the occupancy of the tenured generation exceeds an initiating occupancy. This percentage value can be adjusted with the option `-XX:CMSInitiatingOccupancyFraction=`
  • 37. Incremental Mode • Breaking up the concurrent phases into short burst of activity, which are scheduled to occur mid-way between minor pauses • Especially useful when applications that need the low pause times are run on machines with small numbers of processors (e.g., 1 or 2)
  • 38. Incremental Mode • `-XX:+CMSIncrementalMode`: enables incremental mode. must also be enabled with `-XX:+UseConcMarkSweepGC` • `-XX:+CMSIncrementalPacing`: enables automatic pacing. The incremental mode duty cycle is automatically adjusted based on statistics collected while the JVM is running • `-XX:CMSIncrementalDutyCycle=`: the percentage of time between minor collections that the concurrent collector is allowed to run. Just initial value when CMSIncrementalPacing is enabled
  • 39. Recommended Option for Incremental Mode -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalDutyCycle=10 Java 6 Java 5
  • 40. Explicit Garbage Collection • `-XX:+DisableExplicitGC` causes the VM to ignore calls to System.gc()