Cat Nap memory issues


I purchased a PDF book titled “2D iOS & tvOS Games by Tutorials Updated for Swift 2.2” along with “3D iOS Games by Tutorial” several days ago. I was going to buy the latter and then decided to buy the former at the same time because I wanted to learn how to manage memory issues. But… As I debug the game called “Cat Nap,” memory leaks a big time. If I go through levels a dozen times, the memory will increase by a few hundreds. That is not acceptable at all. Anyway, how do you suggest battling with the leak?

Plus, you have a huge number of typos.

Thank you,

Mr. Tomato

Thanks, we are looking into fixing those. Changes in Swift have been hard to keep up with but we are on it.

In the meantime, have you looked at this tutorial? Its a bit old but the concepts still apply:

No, I haven’t seen it.

I think the problem is the way you start a level. Inside the level method, you create a scene object without pointing to a variable that is accessible through the class. When you win or lose, you don’t remove it. Actually, you can’t remove it since it’s hidden inside the level method. So as you start a new level, all those level scenes are just piling up.