Generate Garbage Collection Logs
If SAP Commerce Cloud receives a Java out of memory exception or shows performance issues, the cause may be related to garbage collection. To determine the root cause of the out of memory or performance issue, take and analyse garbage collection logs.
Context
Garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. Garbage collection is often portrayed as the opposite of manual memory management, which requires the programmer to specify which objects to deallocate and return to the memory system.
Following are the main implementations for garbage collection:
| Type | Details |
|---|---|
| Parallel |
usage: -XX:+UseParallelGC Default for server environments
|
| Concurrent |
usage: -XX:+UseConcMarkSweepGC Industry standard for low latency garbage collection
|
| G1 (Garbage First) |
usage: -XX:UseG1GC Low latency garbage collector for a server-style garbage collector, targeted for multi-processor machines with large memories
|
The Garbage-First (G1) garbage collector is fully supported in Oracle JDK 7 update 4 and later releases. The G1 collector is a server-style garbage collector, targeted for multi-processor machines with large memories. It meets garbage collection pause time goals with high probability, while achieving high throughput. Whole-heap operations, such as global marking, are performed concurrently with the application threads. This prevents interruptions proportional to heap or live-data size.
The parallel Garbage collector needs stop-the-world events to perform the collection of old generation objects. This can lead to pauses longer than one second, which is undesirable from an operations perspective.
The concurrent garbage collector focuses on old objects and must be combined with a young objects collector. For this duty, select the parallel young generation collector:
| -XX:+UseConcMarkSweepGC | Enables the Concurrent Mark Sweep (CMS) garbage collector for old objects |
| -XX:+UseParNewGC | Selects the parallel young generation collector for young objects |