NSURLCache does not respect diskCapacity

Number:rdar://30312749 Date Originated:01-Feb-2017 08:55 PM
Status:Duplicate/29642285/Closed Resolved:
Product:iOS + SDK Product Version:10.2
Classification:Serious Bug Reproducible:Always
This is a duplicate of rdar://29945424


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)


Apple response, February 27 2018

Thank you for contacting us. The original report on this issue, Bug ID 29642285, is closed due to lack of response from the originator. If you still see the issue, please file a new bug report.

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!