I'm running into a strange problem with root proxies in 10.5. I have
been tracking down memory leaks in my app, and it seems that
+rootProxyForConnectionWithRegisteredName:host: has been changed in
10.5 to return the root proxy retained rather than autoreleased. I
haven't seen anything in the docs to reflect this, but testing seems
to prove it. I did run across this curious mention in the Foundation
release notes, though it doesn't really state things one way or the
other:
Leaks in Distributed Objects plugged
Some leaks, and places where objects could leak if the timing was
right, in Distributed Objects have been fixed in 10.5. This may mean
that you may no longer get away with something you used to get away
with due to the leak. Not retaining the root proxy you get from the
connection, if you're going to hold onto it, seems to be a common
pitfall.
Can anyone confirm this, or see anything wrong with the code below
that might lead to this?
Here's a simplified version of the code I'm actually using (not the
entire class, just basic portions of it):
- (id)init
{
if ( (self = [super init]) ) {
NSUInteger numTries = 0;
struct timespec tv = { 0, 250000000 }; /* .25 of a second */
/* threadPortName and threadProxy are class ivars */
if ( threadPortName != nil ) {
threadProxy = [NSConnection
rootProxyForConnectionWithRegisteredName:threadPortName host:nil];
/* Causes threadProxy to never be released under 10.5
when uncommented; crash under 10.4 when commented
*/
//[threadProxy retain];
}