Well, I ended up testing this myself, and then testing a few more comments to get an edited answer.
Using JDK 1.7.0_07 and a test application reporting the name of the virtual machine “Java Server HotSpot (TM) 64-bit Server VM”, the memory granularity of StringBuilder is 4 characters, increasing even by 4 characters.
Answer: any few of 4 is equally good for a StringBuilder from a memory allocation point, at least on this 64-bit JVM.
Tested by creating 1,000,000 StringBuilder objects with different initial capabilities, in different executions of the test program (for the same state of the initial heap) and printing ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() before and after.
It also confirms that the size of the print heap is also confirmed that the amount actually allocated from the heap for each StringBuilder buffer is equal to the even edge of 8 bytes, as expected since Java char has a length of 2 bytes. In other words, allocating 1,000,000 copies with an initial capacity of 1..4 takes about 8 megabytes less memory (8 bytes per instance) than allocating the same number of isntances with an initial capacity of 5 ... 8.
source share