I have found that with leaks, it doesn’t matter how fast you bail, leaks will still take you down! Although the kinds of leaks we see in today’s organizations are different than a water leak, a JVM leak can still be just as disastrous.
There are numerous kinds of JVM leaks.
- Unchecked arrays, Lists, Hash Map Growth
- Not Closing Java Database Connectivity (JDBC) Prepared Statements, Sockets and File Handles
- Thread Leaks, Handle Leaks
- Class Loader Leaks
- Resources allocated outside JVM, such as JNIs
Whether a leak is caused by human carelessness, programming errors or bugs, dealing with composite applications and multiple moving parts can be a real challenge in application development and production support. By the time you are able to identify the problem, it is usually too late to achieve a fix to stop a server failure or a JVM hang.
But, you say “I’m a Java programmer so I don’t have to worry about memory leaks. Garbage Collection (GC) takes care of it”. Well, maybe not as much as you think. Your application may exit, but one of your classes may still be referenced and will not be dereferenced when GC runs. So, it looks like you can have a memory leak. And memory leaks can lead to downtime and you certainly don’t want to be associated with that!
But, to sit and monitor your JVM applications to try to figure out where there is a leak, why there is a leak and how to stop it before a system failure is asking for the impossible…. Almost. What you need is a way to automatically detect memory leak patterns. We have found leaks cannot be detected by JVM usage alone. But when your application performance monitoring efforts are combined with a Momentum Oscillator and include monitoring Heap Utilization, we can detect leaky type behavior. By using this method, you can detect abnormal behavior and mitigate JVM failures.
I’m sure we all agree that application leaks must always either be prevented or fixed as quickly as possible. The server is always busy and we all need to be in control of what the server is spending its time doing. Is it going to handle the thousands of transactions required or is it going to be doing garbage collection and still leave you hanging? None of us can afford down time and by effectively monitoring for memory leaks, we can head off and prevent the possibility of a server failure. For more information on this topic, check out the video, “Detecting Java Memory Leaks”.