uiimage - Image IO memory keeps growing -


i ran app in instruments vm tracker discovered growing image io memory consumption.

instruments initwithcontentsoffile:

effectively, app did quite bit of reading images disk initwithcontentsoffile:. read once method spawn of satan, replaced following:

nsdata *data = [nsdata datawithcontentsoffile:path]; uiimage *image = [uiimage imagewithdata:data]; 

this reduced virtual memory (about 60%), shown below:

instruments imagewithdata:

but, why image io virtual memory keep growing on time, when there aren't leaks , app using 15mb of live memory?

is there can make sure image io memory released?

basically, image reading disk done this:

dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0ul), ^(void) {     nsdata *data = [nsdata datawithcontentsoffile:path];     uiimage *image = [uiimage imagewithdata:data];     dispatch_async(dispatch_get_main_queue(), ^{         imageview.image = image;     }); }); 

i tried following without significant changes:

  • use [nsdata datawithcontentsoffile:path options:nsdatareadinguncached error:nil] instead
  • move uiimage *image = [uiimage imagewithdata:data]; main queue
  • do on main queue

which makes me think problem might elsewhere.

you should @ least wrap background processing autorelease pool:

dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0ul), ^(void) {     @autoreleasepool {         nsdata *data = [nsdata datawithcontentsoffile:path];         uiimage *image = [uiimage imagewithdata:data];         dispatch_async(dispatch_get_main_queue(), ^{             imageview.image = image;         });     } }); 

this way make sure autoreleased objects on background thread go away fast possible.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -