On Sep 9, 2008, at 5:28 PM, Markus Spoettl wrote:
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).


OK, I did some more testing and timing and there is a solution - which I don't understand:

Testing with 326 objects, adding each of the objects to the array like this

   NSMutableArray *kvoArray = [self mutableArrayValueForKey:@"array"];
   for (MyObject *obj in inputData) {
       [kvoArray addObject:newObject];
   }

This takes 580 seconds. Each add causes a chain reaction of events that eventually adds a new NSView to the collection view. I've experimented with setting the whole array at once using -setArray: but that does not make any difference.

However, adding an auto-release pool does make a huge difference:

   NSMutableArray *kvoArray = [self mutableArrayValueForKey:@"array"];
   for (MyObject *obj in inputData) {
       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

       [kvoArray addObject:newObject];

       [pool release];
   }

The same operation now takes 60 seconds. That's 10% of the original time.

What I don't understand is why adding the auto-release pool has such a dramatic impact on registering observers on the objects. Anyone know why?

Regards
Markus
--
__________________________________________
Markus Spoettl

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

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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