• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problems with Key Observing Registration Performance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with Key Observing Registration Performance


  • Subject: Problems with Key Observing Registration Performance
  • From: Markus Spoettl <email@hidden>
  • Date: Tue, 9 Sep 2008 17:28:35 -0700

Hi List,

I'm having a strange problem with key observing performance, namely registering observers.

I have an array of objects which is bound to a collection view and its views register themselves as observers of the array objects' properties (1 object, 1 view). The objects' properties are being observed somewhere else as well. There are 17 properties that are observed like this:

[object addObserver:self forKeyPath:@"prop" options:NSKeyValueObservingOptionNew context:nil];

The time needed to register the observation depends on the number of objects in the array. It increases exponentially. A small portion of the Shark log is here:

0.0% 58.8% rubiTrack -[registerObservers]
0.0% 58.8% Foundation - [NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:]
0.0% 58.4% Foundation - [NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:]
0.0% 41.8% Foundation _NSKeyValueObservationInfoCreateByAdding
8.1% 40.1% Foundation -[NSKeyValueObservationInfo _initWithObservances:count:]
0.5% 29.8% CoreFoundation -[__NSPlaceholderArray initWithObjects:count:]
2.6% 29.1% CoreFoundation CFArrayCreate
14.3% 16.6% CoreFoundation CFRetain


These numbers come from a test case with 140 objects, when I double the object number, the test never finishes (at least not within 10 minutes).

It appears I'm running into a problem with the number of properties that are being observed. When I observe only one property, the above takes up only 0.8% of the CPU time.

Is there a problem with observing may properties of the same object if you have may objects of that kind that are being observed? If so, is there a workaround?

Thanks for any input!
Regards
Markus
--
__________________________________________
Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problems with Key Observing Registration Performance
      • From: Markus Spoettl <email@hidden>
  • Prev by Date: How to determine if the system is started up from firewire disk
  • Next by Date: Re: BOOL array
  • Previous by thread: Re: How to determine if the system is started up from firewire disk
  • Next by thread: Re: Problems with Key Observing Registration Performance
  • Index(es):
    • Date
    • Thread