Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I release UIimage which was fetched from ALAssetsLibrary
    text
    copied!<p>I spent my whole 2weeks for just trying to resolve this problem. So frustrate!</p> <p>Following 2 functions are what I'm using for fetching a image from device library. If I use "setImage" function multiple times I keep losing my free memory on my iOS Device.</p> <p>I think "<strong>[imageFromAsset initWithCGImage:[[myasset defaultRepresentation] fullScreenImage]];</strong>" in assetImage function causes the problem. </p> <p>Can any guys help me? Any clues or thinking would be SUPER appreciate! Please!</p> <pre><code>- (void)setImage:(NSURL *)imageURL{ UIImage *imageFromDeviceLibrary = [[UIImage alloc] init]; [[DevicePhotoControl sharedInstance] assetImage:[imageURL absoluteString] imageToStore:imageFromDeviceLibrary]; UIImageView *fullImageView = [[UIImageView alloc] initWithImage:imageFromDeviceLibrary]; [imageFromDeviceLibrary release]; [self.view addSubview:fullImageView]; [fullImageView release]; } - (void)assetImage:(NSString *)assetURL imageToStore:(UIImage *)imageFromAsset{ // Handling exception case for when it doesn't have assets-library if ([assetURL hasPrefix:@"assets-library:"] == NO) { assetURL = [NSString stringWithFormat:@"%@%@",@"assets-library:",assetURL]; } __block BOOL busy = YES; ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease]; //get image data by URL ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) { [imageFromAsset initWithCGImage:[[myasset defaultRepresentation] fullScreenImage]]; busy = NO; }; ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror) { NSLog(@"Library Image Fetching Failed : %@",[myerror localizedDescription]); busy = NO; }; [assetslibrary assetForURL:[NSURL URLWithString:assetURL] resultBlock:resultblock failureBlock:failureblock]; while (busy == YES) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload