Search

GC easy – Universal Java GC Log Analyser

Tag

JVM argument

All you need to know about System.gc()

The article discusses the System.gc() API call in Java and other languages, clarifying its invocation, use cases, downsides, and detection methods. Invoking System.gc() can halt JVM operations, causing poor user experiences. It also suggests strategies to manage or disable these calls, including using JVM arguments and monitoring GC logs for optimization.

UseStringDeduplication

The article discusses the prevalence of duplicate strings in Java applications, which can waste approximately 13.5% of memory. It introduces the '-XX:+UseStringDeduplication' JVM argument, which helps eliminate these duplicates during garbage collection. However, its effectiveness relies on using the G1 garbage collector and targeting long-lived objects, necessitating careful testing before implementation.

DISAPPOINTING STORY ON MEMORY OPTIMIZATION

A web application's memory optimization attempt revealed disappointing results. Despite using JVM arguments '-XX:+UseG1GC' and '-XX:+UseStringDeduplication', no reduction in memory usage was observed. The application's short-lived string objects led to negligible duplicate strings being eliminated, highlighting the need for code refactoring to prevent duplicate string creation and improve memory efficiency.

System.gc()

The invocation of System.gc() or Runtime.getRuntime().gc() triggers stop-the-world Full GCs, freezing the JVM and potentially degrading user experience. These calls can originate from various sources including developers, libraries, and RMI. Detecting these calls is crucial, and enabling GC logs can help. Possible solutions include using the JVM argument '-XX:+DisableExplicitGC' or configuring RMI's gcInterval properties.

ROTATING GC LOG FILES

Garbage Collection (GC) logs are vital for optimizing application performance and troubleshooting memory issues. Restarting an application can overwrite old GC logs, hindering analysis. Solutions include appending timestamps to log filenames or enabling GC log rotation. Each method has advantages and drawbacks, necessitating careful management to ensure all logs are accessible for future analysis.

Up ↑