> On May 13, 2014, at 13:03 , Trygve Inda <cocoa...@xericdesign.com> wrote: > >> NSAppleEventDescriptor *appleEvent = [NSAppleEventDescriptor >> appleEventWithEventClass: kMyAEClass >> eventID: kMyAEEventID >> targetDescriptor: targetDescriptor >> returnID: kAutoGenerateReturnID >> transactionID: kAnyTransactionID]; > >> AESendMessage([appleEvent aeDesc], NULL, kAENoReply | kAENeverInteract, >> kAEDefaultTimeout); > > What memory model? ARC? > > You’re getting back back a NSAppleEventDescriptor with +0 semantics, which > means (if ARC) it’s going to be locally retained, then released when it goes > out of scope (possibly a scope optimized optimized to the last reference). > > What you’re passing to AESendMessage is an interior pointer (‘aeDesc’ is > marked NS_RETURNS_INNER_POINTER in the headers). AFAIK that keeps the > underlying object alive *in the calling code* long enough for the interior > pointer to be passed safely into the called function, but no longer. > > In particular, I don’t know that the interior pointer can be assumed to be > valid for the entire length of the called function’s execution. Of course, > there’d have to be asynchronous activity (or perhaps a autorelease pool drain > inside the called function) for this to matter, but since you’re not asking > for a reply, that seems possible. > > So, my theory: memory management bug in your code. A simple way to test this > would be to put ‘[appleEvent self];’ after the AESendMessage call, and see if > the problem goes away. >
I am not using ARC. Adding [appleEvent self]; after AESendMessage made no difference at all. When the events happen more slowly, the bug doesn't happen. It is like the AE queue is getting flooded. Adding an [appleEvent retain]; before AESendMessage also makes no difference. Trygve _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com