AlamofireImage how to clean memory and cache
<p>I use Alamofire and AlamofireImage in my app for get data and photos.</p>

<pre><code>        Alamofire.request(.GET, URLString, encoding: .JSON)
        .authenticate(user: user, password: password)
        .responseJSON() { (response) -&gt; Void in
          if let jsonResult = response.result.value {
            if jsonResult.count &gt; 0 {
               ...
               let photo_url = jsonResult[index]["Photo_url"] as! String
               Alamofire.request(.GET, photo_url)
               .authenticate(user: user_photo, password: password_photo)
               .responseImage { response in
                  if let image = response.result.value
                  {
                     button.setBackgroundImage(image, forState: .Normal)
                  }
               }
            }
          }
        }
</code></pre>

<p>I have a crash if user use app for a long time. I can't caught it in the IOS simulator on mac, but I checked and I think if memory in phone finished user have a crash. I use Crashlytics for catch crash but I can't see this crash in the Crashlytics.
I checked logs (access and error) in my Nginx server and also din't see any problems and errors. </p>

<p>After there I think it is problem with memory in the phone. How can I clean cache and memory if I use Alamofire? Can I clean cache Alamofire? </p>

<p>I tried to use this function and clean image in the cache before my photo_url request, but I have the same crash:</p>

<pre><code>func clearImageFromCache(url: String) {
    let URL = NSURL(string: url)!
    let URLRequest = NSURLRequest(URL: URL)

    let imageDownloader = UIImageView.af_sharedImageDownloader

    // Clear the URLRequest from the in-memory cache
    imageDownloader.imageCache?.removeImageForRequest(URLRequest, withAdditionalIdentifier: nil)

    // Clear the URLRequest from the on-disk cache
    imageDownloader.sessionManager.session.configuration.URLCache?.removeCachedResponseForRequest(URLRequest)
}
</code></pre>