NSURLCache does not respect diskCapacity

Number:rdar://29945424 Date Originated:10-Jan-2017
Status:Open Resolved:
Product:iOS + SDK Product Version:10.2
Classification:Serious bug Reproducible:Always

NSURLCache does not respect the value of its `diskCapacity` property. Instead of limiting the on-disk cache to the specified size, it keeps growing uncontrollably, to the order of hundreds of megabytes or more.

Steps to Reproduce:
1. Set the `diskCapacity` property of `NSURLCache.sharedURLCache` to 10 * 1024 * 1024
2. Create http requests (using NSURLSession), downloading data.
3. Continue downloading data, checking the value of `NSURLCache.sharedURLCache.currentDiskUsage` after each response received.

Expected Results:
`currentDiskUsage` should remain less than or equal to `diskCapacity`.

Actual Results:
`currentDiskUsage` grows (far) beyond `diskCapacity`.

10.2 (14C92)


Marked duplicate of rdar://29642285

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!