Iphone 将UIImage插入内存
用这段代码简单地添加一个UIImage,就可以使内存在50MB左右跳跃。图像本身的大小为{24483264}像素:Iphone 将UIImage插入内存,iphone,memory,core-graphics,cgimage,Iphone,Memory,Core Graphics,Cgimage,用这段代码简单地添加一个UIImage,就可以使内存在50MB左右跳跃。图像本身的大小为{24483264}像素: ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) { ALAssetRepresentation *rep = [myasset defaultRepresentation]; CGImageRef iref = [rep fullResolutionImage];
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
if (iref)
{
UIImage *selectedBackground = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];
CGImageRelease(iref);
[self setBackgroundWithImage:selectedBackground orColor:nil];
}
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"Can't get image - %@",[myerror localizedDescription]);
};
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:photoURL resultBlock:resultblock failureBlock:failureblock];
为什么内存会大幅增加?我也有同样的问题。我也对找到解决办法感兴趣。