Memory issues can be hard to diagnose. A useful graph we provide comes from our Collector JVM Garbage Collection metric, which shows how much garbage collection is taking place.
Garbage collection is the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects. An in use object, or a referenced object, means that some part of your program still maintains as a pointer to that object. An unused object, or unreferenced object, is no longer referenced by any part of your program. So the memory used by an unreferenced object can be reclaimed, freeing up memory.
In Java, the process of deallocating memory is handled automatically by the garbage collector. The basic process can be described as follows:
Step 1: Marking
The first step in the process is called marking. This is where the garbage collector identifies which pieces of memory are in use and which are not.
Referenced objects are shown in blue. Unreferenced objects are shown in gold. All objects are scanned in the marking phase to make this determination. This can be a very time consuming process if all objects in a system must be scanned.
Step 2: Normal Deletion
Normal deletion removes unreferenced objects, leaving referenced objects and pointers to free space.
The memory allocator holds references to blocks of free space where new object can be allocated.
In LogicMonitor, extensive garbage collection times may indicate an issue with memory; ideally this should be as low as possible.