Garbage collector tuning in JAVA HOTSPOT JVM
January 29, 2013 Leave a comment
Garbage collector tuning in JAVA HOTSPOT JVM
- GC Basics
- Analysing GC
- Memory Footprint
- Latencies
- Types of Collectors
- Summary
Garbage Collector(GC) Basics
What are GC responsibilities? Garbage detection and reclamation
Garbage Detection: garbage is a collection of objects which are no longer reachable
Garbage Reclamation: makes space for the running program again
Analysing GC
Application Phases
• Initialization ? Steady state ? Summary (optional)
– Initialization – startup, lots of allocations
– Steady state – where application spends the most time, running the ‘core’ part of the application
– Summary – produce report of what has happen, might be computationally intensive and maybe has lots of allocation as well
• Typically, the steady state is the most important
Memory Footprint
Footprint Requirements
• Physical memory available to the VM
– Single VM and dedicated machine
• All physical memory on the machine?
– Multiple Vms / other processes on the machine (eg. DB)
• How much memory is the VM allowed to consume?
Latencies Requirements
• How large are the pauses?
– Average GC pause time target
– Max GC pause time target
– How frequently violations can be tolerated?
• How frequent are the pauses?
– GC pauses frequency target
Choice of Collectors
• Serial GC
– Default, single threaded
– For application with small LDS of up to appox 100MB
• Parallel GC / Parallel Old GC
– Best throughput GC, takes advantage of multi processor
– For medium to large heap
• Concurrent Mark-Sweep GC (CMS)
– Good for managing latencies
– For medium to large heap
– Variant of this is the incremental mode
Summary
• Collect GC data
• Understand your application
• Use the material as a guide
– Don’t be afraid to experiment
• Approach presented
– Start with ParallelOldGC
– Move to CMS when necessary
• Relook at your code
– If GC tuning does not bring any tangible improvements
Recent Comments