StringBuilder default constructor in the class library

Hamada Abdelaziz hamada.kenai at gmail.com
Thu Dec 14 17:03:32 UTC 2017


While analyzing GC pressure of a run time, I noticed the top object 
being a char[], upon a closer inspection, it turns out to be a result of 
ObjectStreamClass use of StringBuilder, which is constructed with the 
default size of 16 bytes.  In such case 16 bytes is not a sufficient 
size, which leads to unnecessary garbage and incurs a performance hit.

In a high volume situation this leads to high GC pressure, and in turn, 
non uniform performance.

It's worthwhile revisiting all uses of StringBuilder default constructor 
in the class library and adjusting it appropriately.

Thoughts?




More information about the core-libs-dev mailing list