I have spent some time debugging a weird issue with ARC and custom dealloc functions.
NSOperation
classDataRequest
DataRequest
holds the ONLY reference to the operation I generate and is destroyed in the operation completion block. It's ALWAYS destroyed (its dealloc
always executed)dealloc
. I have only a single NSLog call in it.... and the issue is:
If I run this under in debugger, the breakpoint in the dealloc is never hit, the log message never appears. Primarily I thought the operation was leaking.
If I run this in instruments, all is fine, the system console prints the message and Allocations instrument reports the operation being freed from the proper stack snapshot including the custom dealloc. No leaks detected.
I'm 100% sure I use the same compiler settings for debugging and for profiling.
The most confusing thing at the end: If I create a custom version of [DataRequest dealloc]
and I put self.operation = nil;
to it - all works fine even from the debugger.
Does anybody have some hints what compiler linker options to try to see some difference? can this be bug in Apple tools (all of us were in the position blaming a big fish for our own errors, right?)
... and yes I have tried with GDB and LLDB. Result was the same - what might indicate something.
I have tried to create a minimalistic sample but it just worked (indeed) ;)
Thanks
Do you have NSZombiesEnabled? We had the same issue and "solved" it by disabling NSZombies.
"Product" -> "Scheme" -> "Edit scheme" -> "Diagnostics" -> Uncheck "Enable Zombie Objects"
I'm not sure why dealloc isn't called when NSZombies are enabled (I'm pretty sure it was called before ARC).
I ran into the same kind of issue today and I took me about 5 hours to find that the problem was caused by NSZombies enabled in my project settings.
I also agree that before ARC, dealloc was called in this case.
After many tests it appears that dealloc is not called if using iOS 5.x (device or simulator).
but it gets called again (with Zombies enabled) in iOS 6.x (device or simulator)
I don't know if this change is caused by a bug in ios5 that has been patched in ios6, or a feature introduced and rolled back.
Hope that helps...
I ran into the same kind of issue today but my problem was a retain cycle generated by a block.
If you're using blocks:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With