Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to:</p> <ol> <li>use CGImageRelease as @zimmryan mentioned</li> <li>use a block of @autoreleasepool in your loop </li> <li>do not store the images in the memory, store them in your Document Directory</li> </ol> <p>This is how I do it: (notice I use the sync version for extracting images, it shouldn't matter if you choose the async version)</p> <pre><code>AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:nil]; AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; generator.requestedTimeToleranceAfter = kCMTimeZero; generator.requestedTimeToleranceBefore = kCMTimeZero; for (Float64 i = 0; i &lt; CMTimeGetSeconds(asset.duration) * FPS ; i++){ @autoreleasepool { CMTime time = CMTimeMake(i, FPS); NSError *err; CMTime actualTime; CGImageRef image = [generator copyCGImageAtTime:time actualTime:&amp;actualTime error:&amp;err]; UIImage *generatedImage = [[UIImage alloc] initWithCGImage:image]; [self saveImage: generatedImage atTime:actualTime]; // Saves the image on document directory and not memory CGImageRelease(image); } } </code></pre> <p><strong>EDIT</strong>: </p> <p>you should always consider using @autoreleasepool when creating alot of temporary objects (see <a href="https://developer.apple.com/library/mac/documentation/cocoa/conceptual/memorymgmt/articles/mmAutoreleasePools.html" rel="noreferrer">https://developer.apple.com/library/mac/documentation/cocoa/conceptual/memorymgmt/articles/mmAutoreleasePools.html</a>) </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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