0

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.

SmokersCough
  • 967
  • 7
  • 22
  • 1
    All I can say is if dealloc isn't called it wasn't released. So you likely still have a memory issue. I'd pull up the allocation instrument, search for the class name of the object that isn't being released, and check the retain counts. You can watch it go up and down. It's probably at +1 still when you think it should be released. Often times this happens because of a strong delegate or a strong reference to self in a block. Good luck! – Ben Kane Jun 08 '15 at 15:51
  • Also, putting an NSLog there shouldn't affect anything. It would still dealloc correctly. Also wouldn't cause a crash. It'd be helpful if you posted the code to your scene that isn't getting deallocated so we can find the problem area. – Ben Kane Jun 08 '15 at 15:52
  • Thanks Ben, i had read in a previous post that putting an nslog in that method in the scene would override the existing dealloc method, i assumed this wasn't the case but was worth asking. It looks like it may be an issue with a strong reference, time for hunting it down. Thanks I'll post some code if i can't figure it out with a little more checking – SmokersCough Jun 08 '15 at 16:34

2 Answers2

1

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.

hamobi
  • 7,940
  • 4
  • 35
  • 64
0

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

SmokersCough
  • 967
  • 7
  • 22