Reputation: 40048
In the following question, it was asked how the niling of weak pointers works in Objective-C:
How does the ARC's zeroing weak pointer behavior implemented?
The answer pointed to this document that seems to include the answer: http://mikeash.com/pyblog/friday-qa-2010-07-16-zeroing-weak-references-in-objective-c.html
The answer is to keep a dictionary/hash table from object to a set of its weak references. But isn't the consequence that each deallocation must then feature a hash table lookup? Isn't this a quite hard performance penalty, especially in case of many short-living objects?
Upvotes: 0
Views: 417
Reputation: 1200
hash table lookup is usually fast but as you correctly state the performance penalty will increase in the case of lots of short lived objects. This however must be balanced against the convenience of the hash table guaranteeing that a weak reference will be valid
Upvotes: 1