- a way to create strings without unnecessary allocations

Jaroslav Tulach jaroslav.tulach at
Wed Dec 8 23:03:39 UTC 2010

Can anybody hear me? I'd like to talk to someone who cares about String, 
StringBuffer and StringBuilder. I am NetBeans Platform architect and I'd like 
to use this opportunity to fasten start of NetBeans as well as improve OpenJDK 
project. Here is my story:

I've been investigating the memory allocations during NetBeans start. I've 
noticed that we are allocating about 60MB of char[] mostly due to parsing of 
various configuration files. Suprisingly at least half of these 60MB is 
garbage collected quickly. This is because we use StringBuffer/Builder to 
concatenate the texts and then convert them to String. The conversion to 
String however allocates new array. I believe this is less then optimal. 
However there is no way I can tell the Java libraries to be more effective.

That is why I decided to create my patch. It adds method 
which can create Strings without unnecessary copying. It adds method too, for symetry, but that one is not that 
effective (I don't know how to make it robust without usage of 
synchronization). If I had, I could allocate only 30MB of 
data on NetBeans startup and very likely make it faster. Can you consider 
adding this method to JDK7?

I am attaching my patch that adds the new API. I can refine it, add new tests, 
etc. I just need a buddy interested in StringBuffer to guide me. I belive that 
together we can make NetBeans start faster and OpenJDK7 better. Can you help 

-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-patch
Size: 3032 bytes
Desc: not available
URL: <>

More information about the core-libs-dev mailing list