I'm using NSOperation and NSOperationQueue in my application. When encounter below warning with EXC_BAD_ACCESS crash, where should I start to debug? I just google it, and didn't find the answer.
Add more information, here is the screenshot of the Debug Navigator
Does it mean that it crashed when releasing something?
UPDATE
I just enabled Zombie Objects and get below information
*** -[AFJSONResponseSerializer release]: message sent to deallocated instance 0x7fdfb378b550
Add more information, I'm not using ARC in my application. For AFNetwork library, I added -fobjc-arc
for each *.m file in AFNetwork.
I wonder:
- According to some answers on stackoverflow I found before, I did not add @autoreleasepool for each NSOperation, am I right?
- Do I also need add
-fobjc-arc
for each *NSOperation.m I implemented in my application? - is it a known issue of AFNetwork?
If you're seeing objc_release as the culprit, then it's trying to release something that's:
(OR your stack has been corrupted so far that it's calling the wrong functions, but this isn't all that likely).
Firstly, expand the ...... and see if it shows anything useful (there's a slider somewhere to show more detail).
Secondly, as a stylistic standpoint, you might want to more directly use blocks instead of NSOperation. Then you can use either
Barring that for the moment, you still need to debug this.
Are you using ARC? If so, this is almost definitely related to a line like one of these:
If not, why aren't you? In this case, you'll have to scour your code to find where you didn't retain something.
I strongly suggest running Xcode's static analyzer and looking very carefully at every thing it highlights - it's really good at spotting these issues since it knows about ownership and transfers thereof.
UPDATE
Since you're not using ARC, things may be harder to find because now the pool of possible issues is larger. Hopefully there aren't many of those classes being allocated.
What I'd recommend is modifying the code to that class add these:
Then put breakpoints on those (plus their initializers and dealloc method) and see where they get called. Then trace that object to find a place you think it doesn't own it but it's still calling -release on it.
The static analyzer is your friend here: use it too.