title: Node disappears during play shows error ...Thread1: EXC_BAD_ACCESS (code=, address= 0x0)
body: <p>I'm using SKAction to scale a node. After about 2 minutes of game play the node disappears. Basic gameplay is you have to keep touching the node to shrink it otherwise it grows. So you can't play if it's not there. I'm not sure why the node disappears now. </p>
  
  <p>code that creates node :</p>
  
  <pre><code>node.create(mainScreenview, position: CGPoint(x: frame.size.width / 2, y: frame.size.height / 2), size: CGSize(width: 150, height: 150), color: greyColour, name: "Test")
  
  
  func nodeAction() {
      node.runAction(SKAction.scaleBy(10.0, duration: 8.5))
  }
  </code></pre>
  
  <p>Function to compare correct answer</p>
  
  <pre><code> func compareNodes() {
  
  if !nodesToCheck.isEmpty {
    let checkThisNode = nodesToCheck[0] as! SKSpriteNode
    if checkThisNode.name == node.name {
      node.physicsBody = nil
      node.removeAllActions()
  
      score += 1
      nodesToCheck.removeAll()
      changeSizeToSmall()
  
  
    } else {
      gameOver()
    }
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>func changeSizeToSmall() {
  </code></pre>
  
  <p>'node.size = CGSize(width: 60, height: 60)'</p>
  
  <p>now <code>SKAction.resizeToWidth(60, height: 60, duration: 1.0))</code></p>
  
  <p>The error message for this line</p>
  
  <pre><code>node.physicsBody = SKPhysicsBody(circleOfRadius: node.size.width / 2)
  </code></pre>
  
  <blockquote>
    <p>Thread1: EXC_BAD_ACCESS (code=, address= 0x0) </p>
  </blockquote>
  
  <p>and always highlights the node's physicsbody. There is nothing between these lines
  and the rest of the node code</p>
  
  <pre><code>    node.physicsBody?.affectedByGravity = false
      node.physicsBody?.categoryBitMask = PhysicsCategory.node.rawValue
      node.physicsBody?.contactTestBitMask = PhysicsCategory.bird.rawValue
      node.physicsBody?.collisionBitMask = 0
  }
  </code></pre>
  
  <p>The app crashes with that error. The memory usage doesn't change too much during the game but it does increase. I've commented out the SKAction line and I can play the game for as long as I like. So I understand that Shrinking the node and adding a physics body uses a lot of memory but I don't know what to do instead. I've tried removing the node after each time it's called and recreating it again. Tried debugging with the instruments to see what is being dealloc, looking for reference cycles but I'm really not sure what I'm looking for. </p>
  
  <p>What can I do to stop this from happening?</p>
  
  <p>Thanks for any help</p>