Catastrophic memory usage with lazy member variable

Originator:colin.myr
Number:rdar://36412111 Date Originated:Jan 10th 2018
Status:Open Resolved:
Product:macOS/Foundation Product Version:10.12.6/9.2
Classification:Bug Reproducible:Always
 
Area:
Foundation

Summary:
Modification of a member of a collection that is itself a lazy instance variable causes the collection to be copied.

Steps to Reproduce:
There is a sample Xcode project at https://github.com/cmyr/swift-lazy-perf

Expected Results:
Modification of the collection should be in-place.


Actual Results:
The collection is copied before each write. If the collection is not trivially small, frequent modifications significantly degrade application performance.


Version/Build:
Xcode Version 9.2 (9C40b)
macOS 10.12.6 (16G1114)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!