Re: Scripting Bridge Strange Pauses
Re: Scripting Bridge Strange Pauses
- Subject: Re: Scripting Bridge Strange Pauses
- From: Dave Keck <email@hidden>
- Date: Thu, 16 Sep 2010 16:31:36 -0400
> It is running on main thread. I am not sure how to "profile." I tried "Thread State" in Instruments and it output data, but nothing unusual when the pause occurred. Is that the right tool?
(Sorry, I meant 'sample' instead of 'profile.')
When the loop gets hung up, pause the program in the Xcode debugger
and copy and paste the main thread's stack trace into a reply to the
list; this will tell us exactly what nested call is blocking the loop.
> I did pinpoint exactly what method was being called when a pause occurred (although the specific method varied) and changed those methods to do nothing except return a number such as
> - (long)birthSDN { return 10L; }
> and it still pauses. It is hard to see how this method could not be responding. Also these pauses never happen when the same methods are called from an AppleScript. They only happen when called from a Python script or a Cocoa app, both through the Scripting Bridge.
If possible, it would help us outsiders a lot if you could distill
your two apps down to the smallest case that still exhibits this
behavior and post them to the list.
> I tried GC in Instruments, but it said my apps do no qualify? Also, I want the final solution to work in Python scripts and not to only work from other Cocoa apps. I am not sure if an autorelease pool method would work from Python script?
> One new result has started as well when running from a Python script. When the long pause is over, some Python variables that were previously defined have changed to "None" and then the script encounters and error. The long pause seems to be corrupting memory as well.
GC doesn't involve Instruments; if you haven't explicitly enabled it
in your test app's Xcode project, then it's disabled by default.
I suggested wrapping your loop with an autorelease pool simply to
remove the potential variable of memory management as being the cause
of the slowdown/pause. The code would look like this with an
autorelease pool present:
for(i=0;i<numRecs;i++)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
id indi=[recs objectAtIndex:i];
… Do stuff …
[pool release];
}
It's unlikely that this will have much an effect, but it's worth doing
in our goal to isolate the root cause of the pause/slowdown. (Of
course, the Python equivalent of this code will handle the memory
management for you.)
_______________________________________________
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