title: Is it necessary to deallocate an AutoreleasingUnsafeMutablePointer? If so, how?
body: <p>With ARC, I can just set all of an object's strong references to <code>nil</code> to deallocate it.</p>
  
  <p>With an <code>UnsafePointer</code> or <code>UnsafeMutablePointer</code>, I need to manage its memory explicitly:</p>
  
  <pre><code>let buffer = sizeof(Int8) * 4
  var ptr = UnsafeMutablePointer&lt;Void&gt;.alloc(buffer)
  defer {
      ptr.destroy()
      ptr.dealloc(someVal)
      ptr = nil
  }
  </code></pre>
  
  <p>But the documentation is ambiguous for <code>AutoreleasingUnsafeMutablePointer</code> objects.  I cannot explicitly call <code>destroy</code> or <code>dealloc</code> on a <code>AutoreleasingUnsafeMutablePointer</code>.</p>
  
  <pre><code>var ptr: AutoreleasingUnsafeMutablePointer&lt;Void&gt; = nil
  defer {
      ptr = nil
  }
  
  // assign something to ptr
  </code></pre>
  
  <p>The name implies that it is autoreleased after it falls out of scope, but do I need to set a <code>AutoreleasingUnsafeMutablePointer</code> to <code>nil</code> in order for it to be autoreleased?</p>
  
  <p>Here's an example where I use an <code>AutoreleasingUnsafeMutablePointer</code> to get a list of all of the classes currently loaded by the runtime.  Note that when invoking the power of the Objective-C runtime some functions require a <code>AutoreleasingUnsafeMutablePointer</code> rather than just a <code>UnsafeMutablePointer</code>:</p>
  
  <pre><code>var numClasses: Int32 = 0
  var allClasses: AutoreleasingUnsafeMutablePointer&lt;AnyClass?&gt; = nil
  defer {
      allClasses = nil // is this required?
  }
  
  numClasses = objc_getClassList(nil, 0)
  
  if numClasses &gt; 0 {
      var ptr = UnsafeMutablePointer&lt;AnyClass&gt;.alloc(Int(numClasses))
      defer {
          ptr.destroy()
          ptr.dealloc(Int(numClasses))
          ptr = nil
      }
      allClasses = AutoreleasingUnsafeMutablePointer&lt;AnyClass?&gt;.init(ptr)
      numClasses = objc_getClassList(allClasses, numClasses)
  
      for i in 0 ..&lt; numClasses {
          if let currentClass: AnyClass = allClasses[Int(i)] {
              print("\(currentClass)")
          }
      }
  }
  </code></pre>