Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seeing where ARC is inserting retain and releases

Is there a compiler option (or some other way) to see where ARC is inserting retain and releases? This is mostly out of curiosity. I can see them in the disassembly code, but that's hard to wade through sometimes.

like image 877
Roger Gilbrat Avatar asked Jan 10 '12 23:01

Roger Gilbrat


People also ask

What method is automatically called to release objects?

Before releasing objects, the CLR automatically calls the Finalize method for objects that define a Sub Finalize procedure. The Finalize method can contain code that needs to execute just before an object is destroyed, such as code for closing files and saving state information.

How ARC works in Objective-C?

Automatic Reference Counting (ARC) is a memory management option for Objective-C provided by the Clang compiler. When compiling Objective-C code with ARC enabled, the compiler will effectively retain, release, or autorelease where appropriate to ensure the object's lifetime extends through, at least, its last use.

What method is automatically called to release objects in IOS?

Sending the autorelease message to an object marks it for autorelease. When the autorelease pool drains at the end of each event loop, it sends release to all the objects it owns. By convention, object-creation class methods return an autoreleased object.

What method is automatically called to release object in Swift?

How Deinitialization Works. Swift automatically deallocates your instances when they're no longer needed, to free up resources.


1 Answers

No. If the compiler were to provide this, you'd get absolutely overwhelmed by the number of retains/releases, since most of them are taken out during the optimization stage. But the compiler can't even do that, because ARC isn't a pre-processing stage. It's part of the compilation. So you're not going to be able to get anything besides looking at the assembly.

like image 163
Lily Ballard Avatar answered Sep 18 '22 17:09

Lily Ballard