Calling Dealloc method in sprite kit

148 views Asked by At

As a test to ensure that scenes are being dealloc'd i've been adding the:

-(void)dealloc{

NSLog(@"scenename Dealloc);
} 

I've noticed that sometimes this method isn't called, i had previous issues with retain cycles which i believe i fixed, the main issue is that surely if it gets called sometimes it should be called every time?

I've also heard that using the nslog in this method in the scene causes its to be overwritten and therefore not called correctly, resulting in the scene not being dealloc'd, is this true? Could this be the problem causing the game to crash at present? I do see memory fluctuations (up and down) even with these log messages in place.

2

There are 2 answers

0
SmokersCough On BEST ANSWER

As has been previously suggested by the people above i had a memory leak and this was resolved via debugging and instruments.

1
hamobi On

If you want to see exactly what objects exist within your game at different points you can use the Allocations instrument. You can find it under XCode > Open Developer Tool > Instruments

arrange the list by name, and look for the name of your project. You should see how many of your different game objects exist in memory there.