Currently, when javac encounters a String concatenation, it converts the code to use a StringBuilder. For example:
String a = String.valueOf(System.currentTimeMillis());
String b = String.valueOf(System.currentTimeMillis());
String c = String.valueOf(System.currentTimeMillis());
String d = a + b + c + "_IND";
becomes something like
String d = new StringBuilder().append(a).append(b).append(c).append("_IND");
Since the StringBuilder is not explicitly sized, the default size is used and often results in expandCapacity calls at runtime when the default size is too small.
While profiling the application we saw many such operations e.g. build keys for various HashMaps, build unique key for each element in JSF etc which results in extra memory usage.
Is there any better way to reduce this.