Re: Adding an associated reference is memory expensive (was: Adding an observer is memory expensive)

2009-09-14 Thread Torsten Radtke
Hi Ken and Greg This is a bug in the associated reference machinery. That code keeps a C++ std::hash_map per augmented object, mapping associated keys to associated values. std::hash_map uses an std::vector internally, and the default hash_map constructor pre-allocates 100 entries for that

Adding an associated reference is memory expensive (was: Adding an observer is memory expensive)

2009-09-11 Thread Torsten Radtke
Is this when the first observer is added to each of the 100k objects? Yes, it happens for the first observer I add. But I expressed the problem not good enough. Adding an observer is realized by adding an associated reference (with objc_addAssociatedObject(), new in Snow Leopard) to the

Adding an observer is memory expensive

2009-09-10 Thread Torsten Radtke
Hi, I observed excessive memory usage (working in a garbage-collected environment under 10.6) if I add an observer to a KVO-compliant object. So if I add an observer to say 10 objects, Instruments shows that 10 2KB blocks of memory are allocated (additionaly there are another