I am create the video using the Array of images . If I select more than 40 images from gallery it gives the Error:Terminated App Due to memory pressure I am use CVPixelBufferRef to create the Video.
I write to create the video
for (int i=0; i<[_slideshowArray count]; i++) { UIImage *img=[_slideshowArray objectAtIndex:i]; buffer = [self pixelBufferFromCGImage:[img CGImage] size:imageSize]; BOOL append_ok = NO; int j = 0; while (!append_ok && j < 9999) { if (adaptor.assetWriterInput.readyForMoreMediaData) { // NSLog(@"Processing video frame (%d,%lu)",frameCount,(unsigned long)[imageArray count]); CMTime frameTime = CMTimeMake(frameCount*frameDuration,(int32_t) fps); append_ok = [adaptor appendPixelBuffer:buffer withPresentationTime:frameTime]; if(!append_ok){ NSError *error = videoWriter.error; if(error!=nil) { NSLog(@"Unresolved error %@,%@.", error, [error userInfo]); } } } else { printf("adaptor not ready %d, %d\n", frameCount, j); [NSThread sleepForTimeInterval:0.2]; } j++; } if (!append_ok) { printf("error appending image %d times %d\n, with error.", frameCount, j); } frameCount++; } [videoWriterInput markAsFinished]; [videoWriter endSessionAtSourceTime:tm]; [videoWriter finishWritingWithCompletionHandler:^{ NSLog(@"Write Ended"); }];
In this code _slideShowArray is my array that is the Array of UIImage. I put the screenshot of the instruments below.
When I create the video At that time memory will increase otherwise it is 9 or 10 MB.
Note : I am use ARC.
After the creating the video it does not release the memory.
I found the memory leaks in this project please help me..