ios - Virtual Memory Exhaustion - Is This To Blame? -
i'm getting unusual , constant build of virtual memory navigate through app, leading boggy performance , memory pressure crash. app physical memory never goes past 10mb 20mb, virtual memory peaking in 200mb 300mb range @ time of crash.
i'm using arc.
basically, i'm thinking problem approach i've taken cellforrowatindexpath / itemforrowatindexpath methods, app intensely based on content provided through tableviews , collection views.
basically, i'm doing dequeueing cells registered custom xib files, not have class file (which think problem) , referencing objects of dequeued cells through tags rather them class , accessing properties.
from code, , i'm gathered, i'm assuming time collection views or tables reload, it's created additional cells doesn't need cells have been created, it's overlaying same content on same cells? or using uilabel *name = (uilabel *)etc.. increasing reference count in places shouldn't be, causing memory usage skyrocket objects aren't being deallocated?
here's snippet of code 1 of intensive portions of app creating items, logic / flow causing virtual memory problems?
- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { uicollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:products_feed_cell_identifier forindexpath:indexpath]; nsdictionary *product = [self.productsfeeditems objectatindex:indexpath.row]; uiimageview *productthumbnailview = (uiimageview *)[cell viewwithtag:products_feed_collection_item_tag_thumbnail]; [productthumbnailview setimagewithurl:[apicontroller resourceurlforuserid:[product objectforkey:@"userid"] resourcename:[product objectforkey:@"thumbnail"]]]; uilabel *productpricelabel = (uilabel *)[cell viewwithtag:products_feed_collection_item_tag_price]; productpricelabel.text = [nsstring stringwithformat:@"$%@", [product objectforkey:@"price"]]; nsstring *likeimage = ([[product objectforkey:@"liked"] isequaltostring:@"1"]) ? @"feedlikeselected.png" : @"feedlikeunselected.png"; uibutton *productlikebutton = (uibutton *)[cell viewwithtag:products_feed_collection_item_tag_like]; [productlikebutton setimage:[uiimage imagenamed:likeimage] forstate:uicontrolstatenormal]; return cell; }
heap allocations & instruments screenshot
the problem come fact images trying server huge. check sizes of images setting setimagewithurl:
. also, caching images?
Comments
Post a Comment