NSCachedURLResponse leaks its data

Originator:jkubicek
Number:rdar://12595667 Date Originated:29-Oct-2012 05:32 PM
Status:Duplicate/12459632 Resolved:
Product:iOS Product Version:5.0+
Classification:Bug Reproducible:Always
 
29-Oct-2012 05:32 PM James Kubicek:
Summary: NSCachedURLResponse leaks from its data method

Steps to Reproduce:


    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.organicshoppermag.com/assets/images/miso_img_large.gif"]];
    NSURLResponse *response = nil;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:NULL];

    NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data];
    NSLog(@"%u",cachedResponse.data.length);

    for (int i = 0; i<10; i++)
    {
        NSData *data = [cachedResponse data];
        NSLog(@"Retain count: %i", (int)[data performSelector:NSSelectorFromString(@"retainCount")]);
    }

Expected Results:

The logged retain count should be constant.

Actual Results:

Retain count increments.

Regression:

Notes:

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!