"Patience is a virtue" – probably not applicable when it comes to working with enterprise web applications, where the average web/mobile user expects pages to load in two seconds or less. The sheer complexity of IT environments handling high transaction volumes and complexity is the norm, and without application performance monitoring, it will be impossible to deliver consistent service levels.
As enterprise Java technology becomes more and more pervasive, understanding the behavior of the garbage collector becomes extremely important to monitor/manage application performance. Garbage Collection (GC) involves traversing Java heap spaces where application objects are allocated. So, it is important to know how frequently garbage collections are occurring and the time it takes for JVM to free memory no longer utilized by application logic. Heavy or excessive garbage collection will often show up as high CPU (the threads identified in high CPU will be the GC Threads).
The amount of time that garbage collection takes is related to the number of live objects in the heap space and not necessarily related to the size of a given Java heap size. The popular in-built or open source tools one can leverage to optimize the JVM for throughput and responsiveness are VisualVM (included with JDK 6 update 7 and later) and NetBeans Profiler.
Here is a list of performance monitoring/profiling stuff that can be performed using VisualVM and NetBeans:
- Capture sophisticated heap profiles using NetBeans profiler. Heap profiling is beneficial for observing frequent garbage collection and provides information about the memory allocation footprint of an application
- NetBeans CPU Profiling using bytecode instrumentation to profile the performance of an application
- Memory Profiling using VisualVM to analyze the memory usage of an application
- View live heap profiling results and traverse object references using NetBeans HeapWalker
- Visually observe garbage collector behavior using VisualVM plugin "VisualGC"
- Monitor surviving generations (or object age); an increasing number over a period of time can be a strong indicator of a memory leak
- Monitor Class loading and JIT compilation using VisualGC
- The number of threads that are currently active within your application, along with a drilldown of what type of threads that are in use
- VisualVM displays real-time, high-level data on thread activity, and thread dumps are very convenient to help diagnose a number of issues such as deadlocks or application hangs
- Analyze code fragment performance and identifying CPU bottlenecks using NetBeans