Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSConnection release] anxiety



On May 4, 2005, at 7:49PM, Andy Lee wrote:

On May 4, 2005, at 8:25 PM, James Bucanek wrote:

My main problem is the lifetime of the NSConnection object itself.  Everything else pretty much takes care of itself, but I can't determine a definative time when the NSConnection object can be released.

If I let my application leak NSConnection objects, it works fine.  ;)

If no one can come up with an answer to this, I might end up creating an NSConnection pool/factory and do some "lazy" garbage collection.


This sounds like a candidate for one of the -performSelector... methods in NSObject, with a delay of 0.  Delayed performs are good for cases when you:

(a) can't send the message you want to send (like -release) right this moment, because

(b) you're in the middle of something (like using the object you would be releasing), but

(c) you want to send the message just as soon as you're done with that something.

Your idea of a NSConnection pool would essentially be a hand-rolled version of delayed performs.

We initially did this for invalidating connections and started getting dozens of unreproducible crash reports from end users.  You'll see things like NSPortDeathNotify in the stack traces if you start to run into this problem.  After a large effort we were never able to come up with a reliable way to close a connection from within a DO call over that connection.  We ended up having to slightly re-architect our threading code so that connections were managed better and did not need to be closed during the DO calls.  All crashes went away at that point.


Your mileage may vary...


-Frank


------------------------------------

Frank M. Midgley

email@hidden

http://homepage.mac.com/knarf/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: [NSConnection release] anxiety (From: James Bucanek <email@hidden>)
 >Re: [NSConnection release] anxiety (From: Andy Lee <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.