String view leaking

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.

Yours,

Sasha

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?

Thanks for your help.

A String is a Struct in Swift, so I believe it should be a copy.

···

*___________________________________*

*James⎥Lead Engineer*

*james@supmenow.com <james@supmenow.com>⎥supmenow.com <http://supmenow.com>*

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

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?

Thanks for your help.

Yours,

Sasha
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users