steipete/SDURLCache — Issue #7: Memory leak whilst reading from disk
Author: Rheeseyb
Created: 2012-01-20 13:43:14+00:00
State: open

There seems to be an issue whilst reading responses cached on disk and it appears to be on this line:

response = [NSKeyedUnarchiver unarchiveObjectWithFile:[_diskCachePath stringByAppendingPathComponent:cacheKey]]

I've split it out into 2 stages (reading the data from file, and then calling unarchiveObjectWithData), and it appears that the leak occurs when unarchiving the data.

This isn't helped by the fact that with iOS5 the following line does nothing for objects over about 52kB in size:

[super storeCachedResponse:response forRequest:request]

meaning objects over that size will be read from disk every time. (I've tested against iOS4, and this line does cache objects over 52kB in memory).