Select Page

Reducing the Wait for Garbage Collection

John Kaufling | | April 21, 2014

Reducing the Wait for Garbage CollectionWhen we’re profiling application code, there’s one common problem in the Java operating environment that has the potential to affect the entire application: Garbage Collection.

In code creation, Garbage Collection is a function of memory management used to eliminate memory allocation issues and increase productivity. Although the process should free up memory in use, it sometimes creates more problems than it solves. It can create latency and other performance issues.

Chuck Ezell, senior applications tuner at Datavail, explains:

When Garbage Collection happens, there are a lot of CPUs consumed. Everyone is waiting. All of the other JVMs, processes, and the threading that’s going on within the JVMs will have to wait until the Garbage Collection process is complete. It can cause a lot of slowness and it can happen across the entire application. And if we’re not monitoring for that — if we have no way to profile our code to see if it’s a Garbage Collection problem — then we are lost.

Using JDK Tools

Some of the tools in the Java Developer Kit — jstack, jstat, and jmap — are easy to use and are free. They can be used to profile application code. These tools only run on the terminal and generate useful information, but don’t retain any information. You can resolve this by creating a file of the raw data. Before you go to a new session or revert to a different directory, you can easily move the raw data into a file.

Ezell explains his process:

I’ll name the file, I’ll give it a server name, I’ll give it a day. That way I can keep the history of what I’ve done. There’s no analysis provided. It’s just the raw data. But it does provide running threads. You can see the memory footprints of JVMs. You can also see Garbage Collection with jstat. You can actually pull live threads that allow you to look at Garbage Collection in a live JVM, in a production environment.

One means to do this is to use jmap to see the memory footprint, then look at the ebb and flow of memory allocation — which helps monitor Garbage Collection — in jstat. You can use it to look at Garbage Collection and different arguments, or the old memory capacity. By adding a timestamp, says Ezell, you can sample and discover what is occurring over time. This can be applied to a particular JVM to see what the Garbage Collection process is doing to the virtual machine over time.

Reactive, Not Proactive

These specific tools are reactive rather than proactive. You must be there when running a JDK tool and it has to be run when there is a problem. Adds Ezell:

They are great tools for firefighting in a reactive situation. They don’t maintain any history or reporting. The output is essentially what you see. It will help you answer questions and it will help you identify real problems now.

Some other tools able to help monitor the process, but offering differing diagnostic capabilities, are HP Diagnostics and AppDynamics. AppDynamics can profile code, for example, down to the thread stack and exceptions without the need for instrumentation. It also works well with Splunk. You can also schedule automatic and diagnostic sessions that will send you e-mail notifications if too many Garbage Collection events are occurring.

This information should make those chores associated with diagnosing and resolving Garbage Collection issues much easier.

If you need assistance or ongoing help with profiling your code, please contact Datavail to discuss a custom solution for your enterprise.

Image by kadmy/123RF.

12c Upgrade Bug with SQL Tuning Advisor

This blog post outlines steps to take on Oracle upgrade 11.2 to 12.1 if you’re having performance problems. Oracle offers a patch and work around to BUG 20540751.

Megan Elphingstone | March 22, 2017

Oracle EPM Cloud Vs. On-Premises: What’s the Difference?

EPM applications help measure the business performance. This post will help you choose the best EPM solutions for your organization’s needs and objectives.

Bobby Ellis | April 10, 2018

Scripting Out the Logins, Server Role Assignments, and Server Permissions

Imagine there are over one hundred logins in the source server and you need to migrate them all over to the destination server. Wouldn’t it be awesome if we could automate the process by generating the scripts for the required tasks?

JP Chen | October 1, 2015

Work with Us

Let’s have a conversation about what you need to succeed and how we can help get you there.

CONTACT US

Work for Us

Where do you want to take your career? Explore exciting opportunities to join our team.

EXPLORE JOBS