I spent some time debugging a weird problem using ARC and custom dealloc functions.
- I will subclass the
NSOperation class - I set the completion block for this operation
- The operation refers to the strong property of a flat object. It allows you to call this
DataRequest object without methods, automatic ivars, two strong properties DataRequest - following all the recommendations, the completion block uses only weak references to local objects (including the operation itself).
- neither the compiler nor the analyzer generate any problems.
DataRequest contains ONLY a link to the operation that I generate and destroyed in the operation completion block. It is ALWAYS destroyed (its dealloc always executed)- My operation has a custom
dealloc . I have only one call to NSLog.
... and the problem:
If I run this in the debugger, the breakpoint in dealloc never hits, the log message never appears. First of all, I thought the operation was proceeding.
If I run this in the tools, everything is fine, the system console prints a message, and the Allocations tool reports that the operation is exempted from the snapshot of the stack, including the user dealloc. No leaks detected.
I am 100% sure that I use the same compiler settings for debugging and profiling.
The most confusing thing at the end: if I create a custom version of [DataRequest dealloc] , and I put self.operation = nil; on it self.operation = nil; - everything works fine even with a debugger.
Does anyone have any hints on what kind of compiler linker options they are trying to see to some extent? Could this be a mistake in Apple tools (we were all in a position blaming big fish for our mistakes, right?)
... and yes, I tried with GDB and LLDB. The result was the same - that could indicate something.
I tried to create a minimalist pattern, but it just worked (really);)
thanks
simpleone
source share