|
|
|
|
|
by GlitchMr
1460 days ago
|
|
I don't think using String::intern makes sense, especially now that Java's garbage collector is capable of deduplicating strings (https://openjdk.org/jeps/192). In the past it could have been used to reduce memory usage when a given string was used a lot, but now there are better ways of dealing with that issue. |
|
If you have (like one our applications did) millions of copies of the string "USA" in memory, that's many megabytes of memory that explicit deduplication can save that the garbage collector can't.
String.intern isn't the way, for all the reasons this post outlines, but just using G1 isn't the right approach either.