How does the Objective-C runtime handle method caching and why is it critical for performance?
Updated May 17, 2026
Short answer
The runtime caches method lookups to avoid repeated expensive class hierarchy traversal.
Deep explanation
When a method is first called, objc_msgSend performs a lookup in the class’s method cache. If not found, it walks the class hierarchy. Once resolved, the selector-to-IMP mapping is stored in a hash table cache. Future calls hit this cache, reducing dispatch from O(n) inheritance traversal to O(1). Cache misses degrade performance significantly in dynamic-heavy apps.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro