0

I've been debugging for several hours, read some articles but still can't find what's wrong.

I've switched on ARC, but I found that my BIDGameScence will be deallocated strangely, and I don't know why.(I've checked that all pointer to BIDGameScene is strong.) I went through call stack when selector dealloc was called, but there's no selector written by myself in the stack(I think the last stack frame is a function used to send a message).

I also tried Zombies, but I just got Message send to deallocated object. An article says that I should use malloc_info, but I'm using lldb and got malloc_info is not a valid command.(I found that there is no gdb in my XCode.)

What's more, I added a NSLog statement in applicationDidReceiveMemoryWarning, but I did't find it in the logging.

Finally I tried to use Product->Analyze, but got nothing.

So, how to debug this error?

I'm using XCode 4.

luk2302
  • 55,258
  • 23
  • 97
  • 137
LouYu
  • 671
  • 1
  • 6
  • 14
  • http://stackoverflow.com/questions/19740200/how-to-debug-exc-bad-access-bug – Vijay yadav May 01 '15 at 13:50
  • 1
    Why are you using such an old version of Xcode? – Gavin May 01 '15 at 13:57
  • applicationDidReceiveMemoryWarning is not related to EXC_BAD_ACCESS errors at all. If you run out of memory, your app gets killed, that's a different kind of crash. about the -dealloc: do you see the AutoreleasePoolPop function in the backtrace when the object gets deallocated? i suspect a data race somewhere, maybe a "nonatomic" property is involved. or some code that isn't yet converted to ARC does a `release` or `autorelease` too much.. You don't have to look for strong vs weak vs unsafe_unretained pointers, because such crashes will be different, too.. – Michael May 01 '15 at 13:57
  • I believe that I've seen this error before when I had accidentally declared a 2nd global variable (gross. I know, but I've changed my ways) within a different class. They were conflicting because they had the same name. If you find that this is the case, an easy fix could probably be to set the variable to static or to implement the variables differently. TLDR: Make sure you don't have multiple variables with the same name that aren't static. – joels May 01 '15 at 15:09
  • "... but I just got 'Message send to deallocated object'". No, you now know a lot more than that: You now know _which_ object was deallocated and _where_ you attempted use use this deallocated object. Now you need to figure out _why_ the object was deallocated before you were presumably done using it. In ARC, objects are deallocated when you no longer have strong references to it. So review your object ownership model to figure out what should have maintained the strong reference to this object and why it didn't. – Rob May 01 '15 at 17:30
  • See [My App Crashed, Now What?](http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1) – Rob May 01 '15 at 17:31

0 Answers0