&gt;A somewhat contrived example<p>It&#x27;s not a contrived example. When Java changed this exact behaviour it caused a lot of pain for people. Code that previously ran in a reasonable amount of time suddenly became impractically slow:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9862556" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9862556</a><p>&gt;may require a quick look at the API docs<p>The behaviour isn&#x27;t specified by the spec. That is why they were able to change it from one release to the next.<p>&gt;premature optimization and all that.<p>The &quot;premature optimization&quot; meme you are parroting contains the implication that at some point optimisation will be necessary. When that happens you have to think about memory management, even in a GC language. The string example given by danieldk is just one of many ways in which that can happen.