These types are essentially single-field structs. The underlying storage is referenced from this field, which has a reference type. While structs cannot have user-defined destructors, the compiler knows when a value of struct type goes out of scope and destroys its fields, which for reference types decrements their reference count.
Slava > On Oct 25, 2017, at 3:29 PM, Daryle Walker via swift-dev > <[email protected]> wrote: > > OK, so the standard collections (Array, Set, Dictionary) are value types with > remote storage. Since they don’t have de-initializers, how would any > reference count get any notification to eventually de-allocate ? Or is the > memory leaked? Or is some sort of secret system-provided de-initalizer added? > > Just thinking of a undiscriminated union idea and wondering how to prevent > this kind of leak. > > Sent from my iPhone > _______________________________________________ > swift-dev mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-dev _______________________________________________ swift-dev mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-dev
