ios - CFData (store) increases upto 200MB when downloading images throughout NSData -initWithContentsOfURL in Background thread -


im using nsdata -initwithcontentsofurl in background thread download 4k images. can see in instruments cfdata (store) keeps growing , goes upto 200mb (at point btw crash) although im using code clear cache

nsurlcache *sharedcache = [[nsurlcache alloc] initwithmemorycapacity:0 diskcapacity:0 diskpath:nil]; [nsurlcache setsharedurlcache:sharedcache]; [sharedcache removeallcachedresponses]; [sharedcache release]; 

that found in this question

the part of code know sure causing problem (i commented , memory didn't grow beyond 50mb) is:

nsurlcache *sharedcache = [[nsurlcache alloc] initwithmemorycapacity:0 diskcapacity:0 diskpath:nil]; [nsurlcache setsharedurlcache:sharedcache];  nserror *error = nil; nsstring *serverpath = [serverimageinfo valueforkey:@"imagepath"]; nsdata *image = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:[serverpath stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]] options:nsdatareadinguncached error:&error];  nsstring *directorypath = [utilities directorypath]; if (image != null && [image length] > 0) {     //nsstring *path = [[nsstring alloc] initwithstring:directorypath];      nsstring *path = [directorypath stringbyappendingpathcomponent:@"arrangementimages"];      if (![[nsfilemanager defaultmanager] fileexistsatpath:path])     {         [[nsfilemanager defaultmanager] createdirectoryatpath:path withintermediatedirectories:yes attributes:nil error:nil];     }      path = [path stringbyappendingpathcomponent:imageinfo.name];     [image writetofile:path atomically:yes];     self.imageinfo.imagepath = path;     [path release]; }  [sharedcache removeallcachedresponses]; [sharedcache release];  //image = nil; [image release]; 

i used [sharedcache removeallcachedresponses]; in conjunction autorelease pool....and cfdata(store) didnt increase beyond 15 mb although downloaded 4k images.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -