What Do The Surviving Generations Metrics Mean?
By Jiri Sedlacek-Oracle on Feb 07, 2007
In VM Telemetry graphs of the Profiler you can see Surviving Generations metrics which can detect potential memory leaks. Here's a three-lines definition of the what the metrics mean:
- a Generation is a set of instances created within the same GC interval (between two garbage collections)
- a Surviving Generation is a Generation that survives at least one garbage collection. The number of survived garbage collections - the generation's age - is its unique identifier
- Surviving Generations (metrics) value is the number of differerent Surviving Generations that are currently alive on the heap (number of Generations with different generation ages)
Typically there are several long-lived objects (like an application's main
JFrame etc.) in an application representing one or a few Surviving Generations. There are also many short-lived objects created very frequently (such as
Dimension etc.) and released soon, typically within only a few garbage collections. They also represent just several Surviving Generations.
After some period of time the number of Surviving Generations in an application should become stable because all long-lived objects have already been created and newly-created short-lived objects are periodically being released from the heap. However, if there is a memory leak in an application which prevents newly-created objects from being released from the heap (for example objects stored in a
Collection and never removed), the number of Surviving Generations grows and that's exactly what the Surviving Generations metrics is able to detect regardless of how much memory is wasted by such a leak.