0

I am developing a simple game with sprite kit. When I run the game on my device I start to change scenes between gameplay, main scene and level scene.However, memory increase in gameplay but 5 times increase unexpectedly and automatically decrease the actual level. I just wait on the gameplay scene and do nothing. As you can see in the graphic.

enter image description here

I try the followings to figure out the issue:

  1. Call deinit method in GamePlay class but it is not calling deinit method while this unexpected decrease occurs.
  2. Use instruments memory allocation but cannot figure out anything.

I use Xcode Debug Session. What do you suggest ? How can I understand why memory increase and decrease that way ?

I am presenting the scenes like that.

let scene = GamePlay(size: self.view!.bounds.size, viewController: viewController)
self.view!.presentScene(scene)

class GamePlay: SKScene {

private weak var viewController: GameViewController?

lazy var TimeToAddLive = CFTimeInterval(600)
var gameOverCurrentTime: CFAbsoluteTime!
var totalWaitTime: CFTimeInterval!
var timePassed: Double!
var timeLeft: Int!
var ballNode: [Balls] = []
let parentLaser = SKNode()
let gameObjectsNode = SKNode()
var allBallsConnected = 0
var gunPoint: CGPoint!
var laserChilArray = [SKSpriteNode]()
var remainingLives = SKLabelNode(fontNamed: "Chalkduster")
let back = SKSpriteNode(imageNamed: "back")
var timeLabel = SKLabelNode(fontNamed: "Chalkduster")

lazy var contactSound : SKAction = SKAction.playSoundFileNamed("laserContact.caf", waitForCompletion: false)
lazy var failSound: SKAction  = SKAction.playSoundFileNamed("fail2.caf", waitForCompletion: false)
lazy var succesSound: SKAction = SKAction.playSoundFileNamed("succes.caf", waitForCompletion: false)
lazy var fadeIn = SKAction.fadeInWithDuration(0.5)
lazy var fadeOut = SKAction.fadeOutWithDuration(0.5)
lazy var frameForAnimation = 0
lazy var fullScreenAdTime = 0
lazy var doubleContact = 0

let deneme = SKSpriteNode()
let tutBox = SKSpriteNode()

let Pi = CGFloat(M_PI)
var RadiansToDegrees: CGFloat {
    get {
        return 180 / Pi
    }
}
var DegreesToRadians: CGFloat {
    get {
        return Pi / 180
    }
}

I think the problem may be in defining the properties. I don't know. So I write my class properties. When I present the GamePlay scene this increase occur. It does not increase when presenting level scene or main scene or game over scene.

Çağatay Kaya
  • 417
  • 1
  • 6
  • 19
  • sorry I can't post an image because of reputation. – Çağatay Kaya Jul 21 '15 at 14:23
  • Need to see some code in order to get an idea of what's going on. Alternatively you can use product -> profile and have a look at allocations in order to determine what is causing the spike in memory allocations. – Chackle Jul 21 '15 at 15:57
  • I try to figure out the problem with instruments but nothing seem wrong or may be I cannot see. How can I understand the spikes in my code ? – Çağatay Kaya Jul 21 '15 at 16:39

0 Answers0