≡ Menu

Troubleshooting GC: Excessive garbage collection

GC is supposed to save the developers from the tedious task of managing the memory (remember malloc and free and how accidentally you can free an object that is actually being referenced somewhere else and thereby causing unexpected errors ??). However, the very same GC can be a resource hog and bring your application to its knees.

What are the symptoms of Excessive Garbage Collection ?

1. No apparent errors in the logs files but the application is extremely slow
2. Restarting application seems to provide relieve for short period but the slowness comes back eventually

What are the causes of excessive garbage collection ?

1. Inadequate heap generational sizes. Say for example, very small young generation.
2. Application code issue – while the application does not run out of memory, there is something in the application that demands lot of memory

How to prevent excessive garbage collection ?

1. Review verbose GC logs and determine if increasing the young generation or tenured generation will help
For example, if you see numerous minor collections at a short period of time, increasing young generation may help
For details on reviewing the vebose gc logs, see my other post ‘Troubleshooting GC: Analyzing verbose gc logs’
2. Use a profiling tool to find the hot spots in the code. The eclipse profiler can be of great help
3. If you absolutely can’t find any smoking guns, you may have to simply expand your application serving infrastructure
by adding more application instances

We come to the last last issue related to memory, but this one can be little hard to diagnose and fix – Native memory.issues

Coming up: Troubleshooting GC: Native memory issues

Previous: Troubleshooting GC: Running out of PermGen Space

 

{ 0 comments… add one }

Leave a Comment