If you have a long residential small substring of a short-lived large parent string, then a large char [] supporting the parent string will not have the right to garbage collection until the small substring goes beyond. This means that a substring can take up much more memory than people expect.
The only time the Java 6 method performed much better was when someone took a large substring from a large parent string, which is very rare.
It is understood that they decided that the tiny operating costs of this change were outweighed by the latent memory problems caused by the old way. The determining factor is that the problem was hidden, not a workaround.
ILMTitan Apr 20 '13 at 18:07 2013-04-20 18:07
source share