Re: Problems with Key Observing Registration Performance
Re: Problems with Key Observing Registration Performance
- Subject: Re: Problems with Key Observing Registration Performance
- From: Negm-Awad Amin <email@hidden>
- Date: Wed, 10 Sep 2008 11:26:45 +0200
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 (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
Amin Negm-Awad
email@hidden
_______________________________________________
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