title: Clear memory of previous ViewControllers when using modal segues?
body: <p>I've been working a photo editing app that takes pictures and passes it on to the 
  next view controller.
  Of course I use AVSession to have the camera preview shown.
  When the picture is taken the current view controller passes the image on to the view controller that has all the editing features.
  I use modal segues to control transition between views.
  The Problem is that when the segue happens there is a increase in memory by 4mb that never gets released.</p>
  
  <p>Viewcontoller-->EditorViewcontoller</p>
  
  <p>EdiorViewcontroller-->Viewcontroller</p>
  
  <p>I also have a segue from the editor to camera,again there is a accumulation of memory.
  A few times back and forth and the app crashes.</p>
  
  <p>I can't post picture due to lack of reputation.</p>
  
  <p>How can I clean the memory of the previous Viewcontroller and just have the current view controller running.</p>
  
  <p><strong>Things I've tried</strong></p>
  
  <p>*setting all the instances to nil.
  *dismissing the view controller.
  *setting the entire view controller to nil.
  *profiled it.
  *using @autorealease.
  *spent hours on the internet searching for a solution.</p>
  
  <p>I use this line of code to perform the segue.</p>
  
  <pre><code>    [self performSegueWithIdentifier:@"effectsegue" sender:self];
  </code></pre>
  
  <p>I even tried using a weak self hoping it might help.</p>
  
  <pre><code>     __weak ViewController *weakself=self;
  
      [weakself performSegueWithIdentifier:@"effectsegue" sender:self];
  </code></pre>
  
  <p>When I profile it,it tells me these lines of code </p>
  
  <pre><code>   NSData *jpegData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
  </code></pre>
  
  <p>and</p>
  
  <pre><code>   [self performSegueWithIdentifier:@"effectsegue" sender:self];
  </code></pre>
  
  <p>are taking memory.</p>
  
  <p>I would like some suggestions and idea as to what can be done to clear memory of previous view controller and free memory,any other alternates other than segues.</p>
  
  <p>I've been working on this for weeks and this is really not allowing me to proceed forward.
  Thanks in advance.</p>