Re:JDK-4513622: keeping a substring of a field prevents GC f...
by masklinn on Sunday March 08, 2015 @03:05PM
(#9166721)
It is probably the case in other languages though (I believe — though I'm open to being wrong — it is in Go, string slicing is implemented through array slicing, so a substring will share the parent string's storage and keep it alive).
[ Parent
| on HN ]
[deleted]
Re:JDK-4513622: keeping a substring of a field prevents GC f...
by masklinn on Sunday March 08, 2015 @03:44PM
(#9166910)
> substrings are mutable
Are you sure? I know that a byte slice []byte is mutable, but I thought slicing a string yielded a string (and strings are immutable), an explicit conversion (and copy) is needed to get the underlying byte slice.