Skip to main content
Known Participant
December 22, 2005
Question

Garbage collection and closure

  • December 22, 2005
  • 7 replies
  • 1027 views
I am running a remote script from bridge that opens a complex dialog in photoshop. I need to run the dialog in photoshop because it displays fonts, styles and actions, which are not available in bridge.

When I close the dialog I return to my bridge script. If I repeated open the remote script with the complex dialog I continue to use up resources and the dialog opens more slowly each time.

If I run the remote script directly from the ESTK I still lose reources and it slows down, but not as significantly as when run as a remote script via bridgetalk.

I think this is caused by inner functions in my dialog, which are creating closures, which in turn are preventing garbage collection.

Has anyone experienced this and do you have any tips to prevent the performance degradation?
This topic has been closed for replies.

7 replies

Known Participant
January 31, 2006
Hey, sorry about that. I got into a busy streak and forgot.

I emailed you the details directly.

I do think you have found a bug. I will report it.

Bob
hillrgAuthor
Known Participant
January 31, 2006
Bob

Never did hear back from you regarding the scripts I emailed you before Christmas. I have completed the script, including some documentation. Are you still interested in seeing it - if so I will email it to you.

Regards
Rory
hillrgAuthor
Known Participant
January 2, 2006
I have now tried to open any dialog or window repeatedly from another dialog in both bridge and photoshopthat employs automatic layout and they ALL eventually start to develop slower loading times. The more complex the dialog/window, with deeply nested controls, the quicker the performance degrades.
hillrgAuthor
Known Participant
December 23, 2005
Will do.
Known Participant
December 23, 2005
Rory_Hill@adobeforums.com wrote:
> Will do.

I'd like to see the part with the closures. I've had code in the past that
causes leaks and this maybe another manifestation of the same problem.

Send me a copy/message over at ps-scripts and I'll take a look.

ciao,
-X
Known Participant
December 22, 2005
Rory,

I'd like to see the code, both implementations because I'd like to nail down what's happening. I think the PS guys might want a look at it.

I probably won't get to it until January, so there's no hurry.

Please send it to:

rstucky@starband.net

And the best of holidays to you as well!

Bob
Adobe Workflow Scripting
hillrgAuthor
Known Participant
December 22, 2005
I was about to try the approach you are suggesting.

I would be happy to send you my code that is causing the problem. I am not sure if you want it, as there are a number of files, all requiring specific folder location.

I can give you one file that runs in the ESTK that causes degradation as you repeatedly run it (but not as much as running as a remote script). Closing and opening photoshop cleans everything up. It has a few timing messages interspersed through the code that report elapsed time in the javascript console.

Let me know if you would like the code.

BTW, the very best of the holidays!

Rory
Known Participant
December 22, 2005
Rory,

I've never seen that before. In PS, the script that displays the dialog executes, then the engine that ran it supposed to be destroyed. Should be no need for garbage collection. Running the script directly in ESTK still uses BridgeTalk, so I would expect little difference.

I'd be curious to know what's happening because each time you run the script, it should be using a fresh scripting engine in PS. Perhaps there's something preventing PS from releasing the engine when BridgeTalk is involved. It that's the case, it would be a bug.

I do have a suggestion - instead of switching to PS, why not ask PS to give you lists of fonts, styles, and actions? You could write a script that put all three into a an array:

// up here create the arrays
var a = new Array();
a[0] = fontArray;
a[1] = styleArray;
a[2] = actionArray;
a.toSource();

eval'ing the message body in the onResult handler would give you all the info you needed to show your dialog in Bridge. Both Bridge and PS use scriptUI, so the dialog you have written should work in either (once you get the information necessary to display it in Bridge).