advancedJVM Internals & Memory
What is String Deduplication in G1 GC and how is it different from the String Pool?
String Deduplication (-XX:+UseStringDeduplication with G1) finds identical strings already on the heap and makes them share one underlying char[] array, reducing memory — unlike the String Pool, which only applies to literals and doesn't touch strings created at runtime.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response