title: Why dismissing view controller is not clearing presented controller from memory?
body: <p>I have 2 controllers. Each of them have only one button on screen. For first controller button is presenting modally second controller, and for second controller button is dismissing presented controller. </p>
  
  <p>Code of first one is simple as door:</p>
  
  <pre><code>class ViewController: UIViewController {
      @IBAction func present(sender: AnyObject) {
          let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
          if let controller = storyboard.instantiateViewControllerWithIdentifier("web") as? UIViewController {
              controller.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal
              self.presentViewController(controller, animated: true, completion: nil)
          }
      }
  }
  </code></pre>
  
  <p>Second controller code contain some extra code for detecting that after dismissing controller still exist.</p>
  
  <pre><code>static var index: Int = 0
  var index: Int
  
  required init(coder aDecoder: NSCoder) {
      self.index = WebViewController.index++
      super.init(coder: aDecoder)
      let timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: "action", userInfo: nil, repeats: true)
  }
  
  func action() {
      NSLog("Class \(self.dynamicType) index is \(self.index)")
  }
  </code></pre>
  
  <p>And all code of second controller looks like:</p>
  
  <pre><code>class WebViewController: UIViewController {
      static var index: Int = 0
      var index: Int
  
      required init(coder aDecoder: NSCoder) {
          self.index = WebViewController.index++
          super.init(coder: aDecoder)
          let timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: "action", userInfo: nil, repeats: true)
      }
  
      func action() {
          NSLog("Class \(self.view) index is \(self.index)")
      }
  
      @IBAction func dismissSelf() {
          if let presentingController = self.presentingViewController {
              presentingController.dismissViewControllerAnimated(true, completion: nil)
          }
      }
  }
  </code></pre>
  
  <p>So when you will run this and press button on first controller screen for first time, then each 5 seconds you will see in console something like:</p>
  
  <p><strong>Class Proj.WebViewController index is 0</strong></p>
  
  <p>But if you will dismiss controller and present is again, then you will see both:</p>
  
  <p><strong>Class Proj.WebViewController index is 0</strong></p>
  
  <p><strong>Class Proj.WebViewController index is 1</strong></p>
  
  <p>As I understand dismissing is not removing from memory presented controller even if nobody is catching him from my side.</p>
  
  <p>Do somebody know what is it and how can i solve it?</p>
  
  <p>Also you can download <a href="https://github.com/VasylKhmil/SampleProject" rel="noreferrer">sample project</a></p>