Incorrect GC Strategy and Configuration

Chapter: Memory Management

Incorrect GC Strategy and Configuration

Often applications rely on the default settings and behavior of the JVM for garbage collection. Unfortunately while some JVMs, like Oracle JRockit, attempt to dynamically deploy the best strategy, they cannot detect whether your application cares more about response time or throughput. Default garbage-collection settings are a performance compromise to make sure that most applications will work, but such settings are not optimized for either type of application. Don’t expect many of your applications to run their fastest and jump their highest without some careful testing and analysis on your part.

Performance of both response time-bound and throughput-oriented applications suffers from frequent garbage collection; however, the strategies for fixing this problem are different for the two kinds of application. Determining the correct strategy and sizing will allow you to remedy the majority of GC-related performance problems, so here are some tools and tactics for finding optimal solutions to the most common GC issues:

When your application has a more variable load pattern, it’s quite difficult to achieve proper young generation sizing. There are a couple of work arounds:

Frequent Major Garbage Collections

Suspending your JVM for a Major GC simply takes longer than for any other GC cycle. Therefore, frequent major GCs can quickly become a big performance problem.

Causes and Solutions

Most applications experience memory constraints from improper young-generation sizing, which results in premature object tenuring (See the Tuning section earlier in this chapter).

General memory constraints are just as often at the root of this problem. Increasing the total memory allocation for the JVM is the usual remedy. However, if the problem persists and you’ve already assigned several gigabytes of memory, the cause is more likely a memory leak, which can lead to an ever-growing old generation and, eventually, an out-of-memory situation.


Incorrect or non-optimized garbage-collection configurations are the most common cause for GC-related performance problems. These are also the easiest to fix, since they do not require any code changes. Memory leaks, as you will see in the next chapter, are a very different story.

Read the Java enterprise performance eBook online

Chapter: Application Performance Concepts

Differentiating Performance from Scalability

Calculating Performance Data

Collecting Performance Data

Collecting and Analyzing Execution Time Data

Visualizing Performance Data

Controlling Measurement Overhead

Theory Behind Performance

How Humans Perceive Performance

Chapter: Memory Management

How Garbage Collection Works

The Impact of Garbage Collection on application performance

Reducing Garbage Collection Pause time

Making Garbage Collection faster

Not all JVMS are created equal

Analyzing the Performance impact of Memory Utilization and Garbage Collection


GC Configuration Problems

The different kinds of Java memory leaks and how to analyse them

High Memory utilization and their root causes

Classloader releated memory issues

Out-Of-Memory, Churn Rate and more

Chapter: Performance Engineering

Approaching Performance Engineering Afresh

Agile Principles for Performance Evaluation

Employing Dynamic Architecture Validation

Performance in Continuous Integration

Enforcing Development Best Practices

Load Testing—Essential and Not Difficult!

Load Testing in the Era of Web 2.0

Chapter: Virtualization and Cloud Performance

Introduction to Performance Monitoring in virtualized and Cloud Environments

IaaS, PaaS and Saas – All Cloud, All different

Virtualization’s Impact on Performance Management

Monitoring Applications in Virtualized Environments

Monitoring and Understanding Application Performance in The Cloud

Performance Analysis and Resolution of Cloud Applications

Start your 15-day free Java monitoring trial!

Try for free Contact us