Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the reference count of an NSObject?

Is there a way to fetch the current reference count for an NSObject (i.e. NSString)?

like image 681
zer0stimulus Avatar asked Apr 14 '10 19:04

zer0stimulus


People also ask

How do I check my reference count?

You can always check the reference count of a variable by using the CFGetRetainCount function. Note: Reference counting is done only to manage memory for reference types (e.g., classes and closures).

How do you find the retain count in an arc?

You will need to click on the info descriptor (the 'i' next to Allocation in the left pane) and click on "Record Reference Counts". You can then profile your app and do a search for the specific class you're looking to inspect.

What is reference count in Swift?

Swift uses Automatic Reference Counting (ARC) to track and manage your app's memory usage. In most cases, this means that memory management “just works” in Swift, and you don't need to think about memory management yourself.


1 Answers

retainCount

But you should consider using CFGetRetainCount instead

like image 153
Ben S Avatar answered Oct 01 '22 21:10

Ben S