title: Terminated App due to memory pressure While creating Video ios
body: <p>I am create the video using the Array of images . If I select more than 40 images from gallery it gives the <strong>Error:Terminated App Due to memory pressure</strong> I am use CVPixelBufferRef to create the Video.</p>
  
  <ul>
  <li><p>I write to create the video</p>
  
  <pre><code>for (int i=0; i&lt;[_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 &amp;&amp; j &lt; 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");
  }];
  </code></pre>
  
  <p>In this code _slideShowArray is my array that is the Array of UIImage.
  I put the screenshot of the instruments below.</p></li>
  </ul>
  
  <p>When I create the video At that time memory will increase otherwise it is 9 or 10 MB.</p>
  
  <p><strong>Note :</strong> I am use ARC.</p>
  
  <p><img src="https://i.stack.imgur.com/ZU8LP.png" alt="enter image description here"></p>
  
  <p>After the creating the video it does not release the memory.</p>
  
  <p>I found the memory leaks in this project please help me..</p>
  
  <p><img src="https://i.stack.imgur.com/qBdlG.png" alt="Memory Leak Image "></p>