NSURLCache does not respect diskCapacity

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

Area:
Foundation

Summary:
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`.

Version:
10.2 (14C92)

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!