
这是我的代码
myImage= image;LoginSinglton*loginobj = [LoginSinglton sharedInstance];NSError *error;NSData *pngData = UIImageJPEGRepresentation(image,scaleValue); //scaleVale is 1.NSArray *paths = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES);Nsstring *documentsPath = [paths objectAtIndex:0]; //Get the docs directoryself.imageCurrentDateAndTime =[self getTimeAndDate]; self.filePathAndDirectory = [documentsPath stringByAppendingPathComponent:@"Photos Dir"];NSLog(@"documents path %@",self.filePathAndDirectory);if (![[NSfileManager defaultManager] createDirectoryAtPath:self.filePathAndDirectory withIntermediateDirectorIEs:NO attributes:nil error:&error]){ NSLog(@"Create directory error: %@",error);}self.imagename= [Nsstring stringWithFormat:@"photo-%@-%@.jpg",loginobj.userWebID,self.imageCurrentDateAndTime]; Nsstring *filePath = [self.filePathAndDirectory stringByAppendingPathComponent:self.imagename];[pngData writetofile:filePath atomically:YES]; //Write the file[self writeImagethumbnailToFolder:image];[self writeImageHomeVIEwthumbnailToFolder:image]; 我也尝试过以下解决方案
UIImageJPEGRepresentation – memory release issue
1-使用@autoreleasepool
2-完成pngData = nil;
但仍面临着记忆问题.
编辑我想我无法传达我的问题.如果UIImageJPEGRepresentation占用大量内存,那就没关系,但是在保存该图像后,内存应该回到它的早期位置.希望这会对你有所帮助.
解决方法 使用小于1的scaleValue.即使0.9也会大大减少内存占用,同时将质量损失降至最低. 总结以上是内存溢出为你收集整理的ios – UIImageJPEGRepresentation占用大量内存全部内容,希望文章能够帮你解决ios – UIImageJPEGRepresentation占用大量内存所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)