title: AVCaptureSession start memory warnings
body: <p>each time I start a AVCaptureSession I receive a memory warning leading to crashes after time.<br>
  I'm starting the session asynchronously and the Instruments tool says the application consumes about 2 MB memory.
  Do you have any idea how to overcome that issue? Are 2MB of allocated memory too much?</p>
  
  <p>Thankx!
  [iOS 4.3, ARC]</p>
  
  <pre><code>@autoreleasepool {
      //Init capture session
      session = [[AVCaptureSession alloc] init];
      session.sessionPreset = AVCaptureSessionPresetPhoto;
  
  
      //Resize container view
      CGRect cameraContainerFrame = cameraContainerView.frame;
      cameraContainerFrame.size = CGSizeMake(320, 426);
      cameraContainerView.frame = cameraContainerFrame;
  
      CALayer *viewLayer = [cameraContainerView layer];
      [viewLayer setMasksToBounds:YES];
  
      //Create preview layer
      captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
  
      CGRect bounds = [cameraContainerView bounds];
      [captureVideoPreviewLayer setFrame:bounds];
  
  
      if ([captureVideoPreviewLayer isOrientationSupported]) {
          [captureVideoPreviewLayer setOrientation:AVCaptureVideoOrientationPortrait];
      }    
      [captureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
  
      [viewLayer addSublayer:captureVideoPreviewLayer];
  
      //Get input device
      captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
  
      if ([captureDevice lockForConfiguration:nil]){
          captureDevice.focusMode = AVCaptureFocusModeContinuousAutoFocus;
          captureDevice.whiteBalanceMode = AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance;
          [captureDevice unlockForConfiguration];
      }
  
      NSError *error = nil;
      AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&amp;error];
      if (!input) {
          // Handle the error appropriately.
          DLog(@"ERROR: trying to open camera: %@", error);
      }
      //Add input to session
      [session addInput:input];
  
      //Output
      stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
      NSDictionary *outputSettings = [NSDictionary dictionaryWithObject:AVVideoCodecJPEG forKey:AVVideoCodecKey];
      [stillImageOutput setOutputSettings:outputSettings];
      [session addOutput:stillImageOutput];
  
      //Save state
      cameraSessionInitialized = YES;
      [session startRunning];
  }
  </code></pre>