[swift-users] String view leaking
jgroff at apple.com
Wed Jan 13 15:03:00 CST 2016
> On Jan 13, 2016, at 10:23 AM, Alexandre Lopoukhine via swift-users <swift-users at swift.org> wrote:
> Hello everyone,
> I have a quick question that I haven’t found an answer to online. Do String.CharacterView, String.UTF8View, String.UTF16View or String.UnicodeView leak the original string? If I store lots of subranges of these, without keeping references to the original, will the originals remain in memory?
> Thanks for your help.
Yeah, slices of Strings or their views will reference a section of the original string. I believe the long-term plan is to change this behavior, so that String always references a complete buffer (like Array), and you have a separate StringSlice type for handling sections (like ArraySlice).
More information about the swift-users