tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Duplicate String values
Date Tue, 01 May 2012 15:04:15 GMT

On 4/28/12 8:58 PM, Konstantin Kolinko wrote:
> 2012/4/27 Christopher Schultz <>:
>> All,
>> I've been doing some memory profiling on my webapp to see where I can
>> reduce our memory footprint a bit by combining equivalent objects.
>> YourKit has some nice utilities to look for duplicate objects --
>> especially Strings.
>> I can see that the string "java.lang.String" has lots of duplicates.
>> Many of the ones I've inspected so far can be traced-back to
>> catalina.mbeans.MBeanUtils and the registry of MBeans that it contains.
>> Would anyone object to using String-interning to share copies of class
>> names for MBeans? I could even restrict such interning to Strings that
>> start with "java.lang" since those are probably the most-used ones, and
>> those strings are probably already interned by all the RTTI
>> infrastructure in the JVM anyway.
> I think that the string returned by class.getName() as well as field
> and method names should be already interned by JVM.
> So instead of String.intern() it should be possible to call class.getName(). :/

That's what I would have expected, but I can see logs of duplicate
String values (like "java.lang.String" for instance), many linked from
JMX beans. I haven't looked at the code, but I'll bet the string values
from directly from the XML files and aren't resolved against actually
Class objects ... that would improve performance a bit during deployment.

> I am OK with your proposal, but I do not expect much savings from
> getting rid of those duplicates.   Does YouKit show some estimates?

It did, but I closed it long ago so I'll have to re-check. IIRC, it was
a couple of MiB. Of course, it's not feasible to check 100% of them
because there were so many copies. I can hack a bit at Tomcat and see
what percentage of them disappear. Then I'll know whether such a change
in Tomcat actually has a meaningful impact.


View raw message