title: SKTextureAtlas staying in memory
body: <p>I made a quick project to understand how SpriteKit frees atlases from memory. Every time the screen is tapped an atlas is created and is loaded into memory. The only reference to the atlas is what you see in the code below and I thought since the var is inside a non-escaping function that it doesn't hold a strong reference. My goal was for the previous atlases loaded into memory to be freed eventually, however memory piles up and eventually crashes. </p>
  
  <p>I understand atlases are only supposed to be loaded in once and the three points Apple makes here (<a href="https://developer.apple.com/library/archive/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Sprites/Sprites.html#//apple_ref/doc/uid/TP40013043-CH9-SW13" rel="nofollow noreferrer">Working with Sprites</a>) about why textures wouldn't be freed</p>
  
  <p>Could someone help me understand why this is the case? </p>
  
  <pre><code>class GameScene: SKScene {
  
       override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
  
          var atlas:SKTextureAtlas? = SKTextureAtlas(named: "Title")
  
          atlas?.preload {
  
              atlas = nil
  
              print("Loaded")
  
          }
  
      }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/voxmP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/voxmP.png" alt="enter image description here"></a>
   A new stair of memory is created each time a touch is detected</p>