Am Mi,10.09.2008 um 03:48 schrieb Markus Spoettl:

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?

When you create an object with +alloc and then release it some lines later, it is possible, that in -init or simply using the object causes others (helper) objects to be created in the ARP. When you release the "front object" you do not handle the "back objects", so they are still alive.

If you use your own ARP, these "back objects" will be released, too.

I assume, that you understand german, so I can link to my article on a german wiki: http://wiki.osxentwicklerforum.de/doku.php? id = wiki:speicherverwaltung &s[]=speicherverwaltung#problemgross_wachsender_arp

Cheers,
Amin




Regards
Markus
--
__________________________________________
Markus Spoettl_______________________________________________

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/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]

Amin Negm-Awad
[EMAIL PROTECTED]




_______________________________________________

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