News for hackers. Stuff that matters.
Re:JVM Anatomy Quark #10: String.intern (2019) by jlmorton on Wednesday June 22, 2022 @04:36PM (#31841551)
One common thing I've seen is an attempt to de-duplicate a poorly-crafted cache.

Let's say you have a cache with Map<Language, BusinessInfo>. After a while, the cache is quite large, and you want to reduce its memory usage. You realize within BusinessInfo, you have a MailingAddress, but it's not actually localized. You're duplicating millions of address lines for no reason.

You could split this out of your cache, but pulling that thread is a bit tricky. Instead, you decide to store addressLine.intern().

There are no comments on this comment yet.