title: Is there a way to clear the cache used by UIImage class?
body: <p>It is well known that UIImage caches its image data when the image is loaded using the <code>imageNamed:</code> method.</p>
  
  <p>From apple documentation:
  <a href="https://developer.apple.com/documentation/uikit/uiimage/1624146-imagenamed" rel="noreferrer">https://developer.apple.com/documentation/uikit/uiimage/1624146-imagenamed</a></p>
  
  <blockquote>
    <p><strong>imageNamed:</strong></p>
    
    <p><em>Discussion</em>: This method looks in the
    system caches for an image object with
    the specified name and returns that
    object if it exists. If a matching
    image object is not already in the
    cache, this method loads the image
    data from the specified file, <strong>caches</strong>
     <strong>it</strong>, and then returns the resulting
    object.</p>
  </blockquote>
  
  <p>Because of that, after loading several images with <code>imageNamed:</code> I noticed a large increase of memory usage  and also that the memory was kept in use even after the controller that loaded the images was dealloc. (at least it didn't increase again when I alloc the same controller)</p>
  
  <p>That made me wonder if there is any way to clear the cache used by UIImage programmatically at any given time of my application lifecycle or even control some cache parameters (like the maximum memory that it can use, for example)</p>
  
  <p>I know that I could easily solve this problem by using <code>initWithData</code>, <code>imageWithData</code>, <code>imageWithContentsOfFile</code> or any other initializer instead of <code>imageNamed</code>, but this cache behavior is desired when using several images, like inside a <code>UITableView</code>.</p>
  
  <p>Any thoughts on how to accomplish that?</p>
  
  <p>EDIT:
  After some answers I just want to make it clear that there is a huge gap between needing to do something and having the possibility to do something. As I pointed out, I know that the OS takes care of that cache for me, I am just trying to see the limitations that the iOS SDK imposes.</p>