How to debug over-release in Objective-C with ARC?

I'm getting a runtime assertion failure like this:

"<FFRender3DView 0x616000271580> has reached dealloc but still has a super view. Super views strongly reference their children, so this is being over-released, or has been over-released in the past."

Looking at the code, I can't see any strong reference to the view except by its superview, so I can't see how it could be released other than by removal from its superview. My first instinct was to override release and set a breakpoint there, but that's not possible in ARC code.

Answered by JWWalker in 794130022

I've gotten rid of the assertion failure, but I can't say I understand how. I had code that retrieves a view pointer via a void* output parameter of a library function, like so:

NSView* theView = nil;
Q3Object_GetProperty( inDC, 'PWin', sizeof(void*), nullptr, &theView );

When I changed it to the following code, the error went away:

NSView* theView = nil;
void* rawViewPtr = nullptr;
Q3Object_GetProperty( inDC, 'PWin', sizeof(void*), nullptr, &rawViewPtr );
theView = (__bridge NSView*) rawViewPtr;

I've gotten rid of the assertion failure, but I can't say I understand how. I had code that retrieves a view pointer via a void* output parameter of a library function, like so:

NSView* theView = nil;
Q3Object_GetProperty( inDC, 'PWin', sizeof(void*), nullptr, &theView );

When I changed it to the following code, the error went away:

NSView* theView = nil;
void* rawViewPtr = nullptr;
Q3Object_GetProperty( inDC, 'PWin', sizeof(void*), nullptr, &rawViewPtr );
theView = (__bridge NSView*) rawViewPtr;
Accepted Answer

Yep, that’d do it. In your first code snippet theView is a strong reference but you’ve populated it with an unowned reference ‘behind the back’ of ARC. In the second code snippet you’re correctly converting the unowned reference to a strong reference by the bridge transfer.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to debug over-release in Objective-C with ARC?
 
 
Q