iphone - Memory issues using ASIHTTPRequest or Image Resizing -


i can't tell i'm having memory issues uploading images server. after 10 or successful uploads memory warnings of level 1 next time quits due dateformatters or being out of memory. here code. uses asihttpdatarequest , image resize function. cant tell if request thats not being released or if image resizing function not releasing image. images huge photos taken phone @ normal high resolution resized print size , uploaded. somewhere along line i'm missing memory management somewhere , driving me mad!

i'm getting memory warnings after 10 or more uploads server using following code. there memory management specific asi i'm not using?

hi i'm using software i'm running huge memory issues. memory warnings , i'm not sure how clear them out without breaking upload. wondering if take @ code sample , maybe show me i'm doing wrong causes memory issue?

i'm getting memory warnings after 10 or more uploads server using following code. there memory management specific asi i'm not using?

hi i'm using software i'm running huge memory issues. memory warnings , i'm not sure how clear them out without breaking upload. wondering if take @ code sample , maybe show me i'm doing wrong causes memory issue?

i'm getting memory warnings after 10 or more uploads server using following code. there memory management specific asi i'm not using?

hi i'm using software im running huge memory issues. memory warnings , i'm not sure how clear them out without breaking upload. wondering if take @ code sample , maybe show me i'm doing wrong causes memory issue?

-(void)uploadphoto:(uploadobject*)upobject{  uiimage *image=[uiimage imagewithcontentsoffile:[upobject.imageobj.imagelist objectatindex:0]];  if([upobject.imageobj.imgtype isequaltostring:@"single"]){   image=[self image:image byscalingandcroppingforsize:cgsizemake(1800, 1200)];  }else if([upobject.imageobj.imgtype isequaltostring:@"standard8x10"]){   image=[self image:image byscalingandcroppingforsize:cgsizemake(3000, 2400)];  }else if([upobject.imageobj.imgtype isequaltostring:@"mouse"]){   image=[self image:image byscalingandcroppingforsize:cgsizemake(2850, 2400)];  }else{   image=[self image:image byscalingandcroppingforsize:cgsizemake(1800, 1200)];  }  nsfilemanager *filemanager = [nsfilemanager defaultmanager];  [filemanager setdelegate:self];  nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);  nsstring *documentsdirectory = [paths objectatindex:0];  nsdata *data = [nsdata datawithdata:uiimagejpegrepresentation(image, 100.0f)];//1.0f = 100% quality  [data writetofile:[upobject.imageobj.imagelist objectatindex:0] atomically:yes];  __block asiformdatarequest *request = [asiformdatarequest requestwithurl:[nsurl urlwithstring:@"http://api.postalpix.com/order/new"]];  [request setpostvalue:upobject.imageobj.pixid forkey:@"uid"];  [request setpostvalue:upobject.orderid forkey:@"orderid"];  [request setpostvalue:upobject.cost forkey:@"total"];  [request setpostvalue:@"none" forkey:@"coupon"];  [request setpostvalue:[nsstring stringwithformat:@"%d",upobject.total] forkey:@"images"];  [request setpostvalue:upobject.block forkey:@"block"];  [request setpostvalue:currentcoupon forkey:@"coupon"];  [request setpostvalue:[nsstring stringwithformat:@"%d",[upobject.imageobj.copies intvalue]] forkey:@"quantity"];  [request settimeoutseconds:20];  request.showaccurateprogress = yes;  [request setuploadprogressdelegate:self];  [request setdelegate:self];  [request setfile:[upobject.imageobj.imagelist objectatindex:0] forkey:@"upfile"];  if ([upobject.imageobj.imgtype isequaltostring:@"single"])  {   [request setpostvalue:@"29375" forkey:@"sku"];   [request setpostvalue:@"4x6 print" forkey:@"description"];   }else if ([upobject.imageobj.imgtype isequaltostring:@"mouse"])  {   [request setpostvalue:@"28925" forkey:@"sku"];   [request setpostvalue:@"photo mouse pad" forkey:@"description"];  }else if ([upobject.imageobj.imgtype isequaltostring:@"standard8x10"])  {   [request setpostvalue:@"29376" forkey:@"sku"];   [request setpostvalue:@"8x10 print" forkey:@"description"];  }  request.shouldcontinuewhenappentersbackground=yes;  [request setcompletionblock:^{   nsdictionary *jo=[[request responsestring] jsonvalue];   nsfilemanager *filemanager = [nsfilemanager defaultmanager];   [filemanager removeitematpath:[currentup.imageobj.imagelist objectatindex:0] error:null];   [self removefinishedupload:currentup.block];   currentup=[self getnextuploadobject];   if(currentup){    [self uploadphoto:currentup];   }else{    currentuploadcount=0;    [[nsnotificationcenter defaultcenter] postnotificationname:@"updatemorebadge" object:nil];    isuploading=no;    [[nsnotificationcenter defaultcenter] postnotificationname:@"hide_progress" object:nil];   }  }];  [request setfailedblock:^{   nserror *error = [request error];   [self restartupload];  }];  [request startasynchronous]; }   - (uiimage*)image:(uiimage *)image byscalingandcroppingforsize:(cgsize)targetsize {  uiimage *sourceimage = image;  uiimage *newimage = nil;          cgsize imagesize = sourceimage.size;  cgfloat width = imagesize.width;  cgfloat height = imagesize.height;  cgfloat targetwidth = targetsize.width;  cgfloat targetheight = targetsize.height;  cgfloat scalefactor = 0.0;  cgfloat scaledwidth = targetwidth;  cgfloat scaledheight = targetheight;  cgpoint thumbnailpoint = cgpointmake(0.0,0.0);   if (cgsizeequaltosize(imagesize, targetsize) == no)   {         cgfloat widthfactor = targetwidth / width;         cgfloat heightfactor = targetheight / height;          if (widthfactor > heightfactor)     scalefactor = widthfactor; // scale fit height         else    scalefactor = heightfactor; // scale fit width         scaledwidth  = width * scalefactor;         scaledheight = height * scalefactor;          // center image         if (widthfactor > heightfactor)   {    thumbnailpoint.y = (targetheight - scaledheight) * 0.5;    }         else     if (widthfactor < heightfactor)    {     thumbnailpoint.x = (targetwidth - scaledwidth) * 0.5;    }  }          uigraphicsbeginimagecontext(targetsize); // crop   cgrect thumbnailrect = cgrectzero;  thumbnailrect.origin = thumbnailpoint;  thumbnailrect.size.width  = scaledwidth;  thumbnailrect.size.height = scaledheight;   [sourceimage drawinrect:thumbnailrect];   newimage = uigraphicsgetimagefromcurrentimagecontext();  if(newimage == nil)        uigraphicsendimagecontext();  return newimage; } 

i think line

if(newimage == nil)      uigraphicsendimagecontext(); 

is not correct. uigraphicsendimagecontext() must invoked no condition.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -