title: iOS 7 Sprite Kit freeing up memory
body: <p>I am building an iOS game aimed for the new iOS 7 and Sprite Kit, using emitter nodes and physics to enhance gameplay. While developing the app, I ran into a serious problem: you create your scenes, nodes, effects, but when you are done and need to return to the main screen, how do you free up all the memory allocated by these resources?</p>
  
  <p>Ideally ARC should free up everything and the application should get back to the memory consumption level it had before creating the scene, but this is not what happens.</p>
  
  <p>I've added the following code, as the dealloc method of the view, which draws the scene and is responsible for removing everything upon getting closed (removed):</p>
  
  <pre><code>- (void) dealloc
  {
      if (scene != nil)
      {
          [scene setPaused:YES];
  
          [scene removeAllActions];
          [scene removeAllChildren];
  
          scene = nil;
  
          [((SKView *)sceneView) presentScene:nil];
  
          sceneView = nil;
      }
  }
  </code></pre>
  
  <ul>
  <li>sceneView is a UIView, which is the container of the scene</li>
  <li>scene is an extension of the SKScene class, creating all the SKSpriteNode objects</li>
  </ul>
  
  <p>I would very much appreciate any help on this matter.</p>