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.
I try the followings to figure out the issue:
- Call deinit method in GamePlay class but it is not calling deinit method while this unexpected decrease occurs.
- 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.