In JDK9, the CDS shared archive can contain interned strings. The bodies of these strings will never be garbage collected. They are also shareable across different JVM processes that map the same CDS archive.
The String Deduplication framework maintains a hashtable of the bodies of all the unique strings.
String Deduplication and Shared Interned Strings should work together in the following ways to minimize memory footprint:
[1] The CDS archive could potentially contain a large number of Strings (hundred of thousands Strings for some server applications). They are guaranteed to be unique. Therefore, we can save space if we do not enter the bodies of these Strings into the deduplication hashtable.
[2] If a dynamically created string has the same content as a shared interned string, after deduplication, the dynamic string should use the body of the shared interned string.
[3] We need to ensure that String deduplication does not modify the String objects stored in the CDS archive.
NOTE: [1] may cause more overhead when doing a lookup, since now you have to search both the shared interned string table, and the dedup hash table.
The String Deduplication framework maintains a hashtable of the bodies of all the unique strings.
String Deduplication and Shared Interned Strings should work together in the following ways to minimize memory footprint:
[1] The CDS archive could potentially contain a large number of Strings (hundred of thousands Strings for some server applications). They are guaranteed to be unique. Therefore, we can save space if we do not enter the bodies of these Strings into the deduplication hashtable.
[2] If a dynamically created string has the same content as a shared interned string, after deduplication, the dynamic string should use the body of the shared interned string.
[3] We need to ensure that String deduplication does not modify the String objects stored in the CDS archive.
NOTE: [1] may cause more overhead when doing a lookup, since now you have to search both the shared interned string table, and the dedup hash table.