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 100000 objects, Instruments shows that 100000 2KB blocks of memory are allocated (additionaly there are another 100000 48B blocks and 200000 32B blocks). The stack trace for the 2KB blocks looks like this:

[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] [NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:]
NSKeyValueReplaceObservationInfoForObject
Auto::Zone::set_associative_ref(void*, void*, void*)
std::vector<__gnu_cxx::_Hashtable_node<std::pair<void* const, void*> >*, Auto::AuxAllocator<__gnu_cxx::_Hashtable_node<std::pair<void* const, void*> >*> >::reserve(unsigned long)

If I overwrite the observationInfo and setObservationInfo: methods and add an instance variable to the observed object, everything is fine. I filed this under rdar://7212101, but would like to know the opinion of this list, too.

Additionaly, if I remove the observer only 100000 32B blocks are released and collected. This also does not seem right to me.

Thanks,
Torsten
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to