Dismal performance of String.intern()

Alan Bateman Alan.Bateman at oracle.com
Tue Jun 11 09:28:14 UTC 2013

On 10/06/2013 19:06, Steven Schlansker wrote:
> Hi core-libs-dev,
> While doing performance profiling of my application, I discovered that nearly 50% of the time deserializing JSON was spent within String.intern().  I understand that in general interning Strings is not the best approach for things, but I think I have a decent use case -- the value of a certain field is one of a very limited number of valid values (that are not known at compile time, so I cannot use an Enum), and is repeated many millions of times in the JSON stream.
Have you run with -XX:+PrintStringTableStatistics? Might be interesting 
if you can share the output (it is printed just before the VM terminates).

There are also tuning knobs such as StringTableSize and would be 
interesting to know if you've experimented with.


More information about the core-libs-dev mailing list