String deduplication is a JVM feature that saves memory by detecting strings with identical values and consolidating their internal byte arrays into a single instance. Introduced in Java 8 for the G1 garbage collector, it operates on the underlying byte array rather than the String object itself. To avoid excessive CPU overhead, deduplication is only attempted on strings that have reached a certain age. ZGC also supports this feature since Java 18. It can be enabled with the JVM flag -XX:+UseStringDeduplication.

1m watch time

Sort: