Skip to main content
Known Participant
May 14, 2020
Question

Script slows down over time

  • May 14, 2020
  • 5 replies
  • 3619 views

Hi, I'm running a script that is fairly simple but it creates lots of images. The script starts off very fast creating about 40 images a minute. However, each minute the script runs it saves about 1 less image.

 

My problem is that this is basically making the script only good for creating about 1500 images. 

Does anybody know what could make a script slowly slowdown?

 

I'm closing each file so there is no buildup of open documents. 

 

I have tried programmatically and through actions to copy -> paste my images but both methods produce the same results mentioned above.

 

Script: https://www.dropbox.com/s/7rpksauwkcda0bm/_All_Options_01.jsx?dl=0

 

UPDATE 2

 

I thought I would make a simpler script and start from there. However this "new" script while faster is still having the same issues, slowing down over time. Hopefully, it will be easier to see what is going on.

 

New Script: https://www.dropbox.com/s/22jnkf0xlg0wvu7/_All_Options_02.jsx?dl=0

 

Here are some numbers, files created per minute.

Original script

92

85

80

71

 

New script

114

103

94

84

 

UPDATE 3

Just added purge to the action but this makes no difference.

 

UPDATE 4 Adobe Support

 

Support

I checked with the my resources. It is based on algorithm and it is the automated process on photoshop. Only thing we can do it to check the performances which my colleague already helped.
 
Me
So this is a known issue? And there is no fix?
 
Support
Yes, this is a known issue. It can be fixed on upcoming update, We didn't have any notification from engineers team yet.
 
Me
Well this has been an issue for a while can you please ask them to fix this. Thank you very much for helping me understand the problem!
 
Support
I will pass this to my senior team.
 
 
 

Thanks,

Dave.

 

This topic has been closed for replies.

5 replies

Legend
May 14, 2020
This line should cause an error.
app.activeDocument.suspendHistory();

There are no try-catch blocks in your script.
Does it even work correctly?

What does the action do?
app.doAction("All_Options","Scripts");
 
Known Participant
May 15, 2020
app.activeDocument.suspendHistory();

Yes it did! Sorry I was just trying things and forgot to take it out.

 

Please see the new script which is a slimmed-down version that kind of does the same thing but still has the same problem. Hopefully, it will be easier to understand.

c.pfaffenbichler
Community Expert
Community Expert
May 15, 2020

What is in the Action "All_Options_New"? 

Kukurykus
Legend
May 14, 2020

I don't remember how is called this kind of loop with a function (can anyone remind me?):

nickyLoop(numberFolders); / But try without it, simply with only for statement.

Known Participant
May 14, 2020

Thanks Kukurykus, I don't know and I will try but I'm doubtful that this is the problem as this nickyLoop(numberFolders); just runs at the start, it's not something that should slow the script over time.

 

However, I don't see what the problem is so I will try.

Kukurykus
Legend
May 14, 2020

Ah then I'm sorry. If at beginning only, then probably it won't help.

JJMack
Community Expert
Community Expert
May 14, 2020

To tell the truth I only hack a scripting I do not actually know javascript of Photoshop scripting well. I got lost in your script somewhat  I  did not  understand what was going on when a file was missing what was being duplicated  what was being opened and copied to the clipboard and closed or what your action was doing with what was copied to the clipboard. Could the Action  be adding a document into Photoshop.

 

 

 

JJMack
Known Participant
May 14, 2020

Hi JJMack, thanks for taking a look. I know that the script looks complicated but all that is happening is that an image is being opened, image A. Then another image is opened, image B. Image B is copied and closed. B is pasted onto A, saved, and closed.

 

Then it all happens again. I know that everything is being closed, there is only one image that is left open*.

 

* I have tried the script where it closes all files and reopens but this does not solve the problem.

 

JJMack
Community Expert
Community Expert
May 14, 2020

After the save do you close the document? You should post ant script you have a problem with so others can see how the script is coded.

JJMack
Known Participant
May 14, 2020

I've added my script! Thanks.

c.pfaffenbichler
Community Expert
Community Expert
May 14, 2020

To me talking about a Script but not providing it seems similar to talking about an image but not showing it. 

 

Does the Script utilze AM or DOM code (or in which »direction« does the mixture lean)? 

Have you tried incorporating purging? 

Is space plentuful on the target volume and the scracth disk? 

Is any data being collected (a list of the files’ names, …)? 

Known Participant
May 14, 2020

Script added! Thanks.