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?
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).
-Joe
···
On Jan 13, 2016, at 10:23 AM, Alexandre Lopoukhine via swift-users <swift-users@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?
On Wed, Jan 13, 2016 at 6:23 PM, Alexandre Lopoukhine via swift-users < swift-users@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?