Memory leak in NSRegularExpression.stringByReplacingMatches(in:options:range:withTemplate:)

Originator:dloewenherz
Number:rdar://30018587 Date Originated:13-Jan-2017 03:03 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:10.2 (14C89)
Classification:Crash / Hang / Data Loss Reproducible:Always
 
Area:
Foundation

Summary:
stringByReplacingMatches(in:options:range:withTemplate:) in NSRegularExpression leaks memory. Applications that call this method repeatedly will inevitably be terminated by iOS due to memory pressure.

Steps to Reproduce:
1. Download the attached project, Radar13Jan2017.zip.
2. Build and run with any iPhone simulator.


Expected Results:
The app runs indefinitely.

Actual Results:
After a few minutes, all of the memory on the system is allocated and the app crashes. You can view the constant allocation growth in the debug pane in Xcode.

Version:
iOS 10.2 (14C89)

Notes:


Configuration:
iPhone SE 64GB T-Mobile

Attachments:
'Radar13Jan2017.zip' was successfully uploaded.

Comments

GitHub project at https://github.com/dlo/Radar30018587

By dloewenherz at Jan. 13, 2017, 10:22 p.m. (reply...)

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!