3

I'm working on a simple SpriteKit game in Xcode 7.2 and I noticed I was getting memory leaks. I was able to eliminate the leaks by commenting out lines such as this:

sword.physicsBody = SKPhysicsBody(rectangleOfSize: sword.size, center: centerPoint)
hero.physicsBody = SKPhysicsBody(circleOfRadius: heroSize)

Basically whenever initializing a new physics body.

I did some research and found several posts such as this where people are having similar problems but all the posts mentioning such a problem are from several years ago.

I just wanted to try again and see if there are any new thoughts or fixes for this problem.

Community
  • 1
  • 1
oli
  • 136
  • 1
  • 11
  • This isn't a fix, but it will work ok for my purposes. I found that manually setting all `.physicsBody = nil` when gameplay is over pauses the memory leak. That way memory isn't leaking while users are sitting on menus. Actual gameplay time should be short enough that the memory leak doesn't have any significant effect. – oli Jan 11 '16 at 02:50
  • Are you sure this happens everytime? For me it occurred only in debug mode with skView.showsPhysics = YES; since game never been released and I always ran it with showPhysics. – okutane Oct 11 '16 at 14:12

0 Answers0