Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory Leak for .showsPhysics

I have just recently spent the past 5 hours trying to debug a memory leak in my Spritekit App.

After app Launch, I noticed a small climb in my memory usage.

I spent 3 of those 5 hours digging through reference material, learning about strong VS Weak with ARC (Definitely Recommend Reading up on that for Intermediates Such as myself)

Is anyone else experiencing this issue? If so is there any sort of explanation? Here is a small snippet of my GameViewController:

class GameViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    if let scene = MainMenu(fileNamed:"MainMenu") {
        // Configure the view.
        let skView = self.view as! SKView
        skView.showsFPS = true
        skView.showsNodeCount = true
        skView.multipleTouchEnabled = true
        skView.showsPhysics = true

        /* Sprite Kit applies additional optimizations to improve rendering performance */
        skView.ignoresSiblingOrder = true

        /* Set the scale mode to scale to fit the window */
        scene.scaleMode = .Fill

        //var GameSaveData = GameData()

        // Scene Config
        //scene.Landscape = "Test_Landscape"
        //scene.Area = "Start"

        skView.presentScene(scene)
    }else{

        print("Couldn't Load Game Scene")
    }
}

As you can see, I'm not doing anything out of the ordinary here. I would Post my gamescene code, but it was all commented out at the time I was still observing the memory leak.

like image 378
luckybroman5 Avatar asked Jan 18 '16 02:01

luckybroman5


2 Answers

Eventually, out of fustration, I just started commenting lines of code, then building and profiling until the memory leak was solved.

Turns out in my GameViewController.swift file,

skView.showsPhysics = true

was the culprit. This must be somewhat of a new bug seeing as how I haven't seen this issue in < IOS 9.2

like image 93
luckybroman5 Avatar answered Nov 05 '22 05:11

luckybroman5


skView.showsFPS = true
skView.showsNodeCount = true
skView.showsPhysics = true

Will leak memory by at least .3 MB/s.

Furthermore...

skView.showsFields = true

enter image description here

Leaks memory at a rate of 30-40 MB/s. Bad, Apple!

like image 25
JRam13 Avatar answered Nov 05 '22 03:11

JRam13