Crash when batching thousands of images with complex script
I am trying to batch large numbers of high-res images through my processing script (about 3000 lines of js) that saves various sizes and crops of the images as well as pasting them into smart objects in template files, saving out listing images and writing to csv file to track the data. Everything works fine for a few hours and through almost a thousand of the images but then Photoshop tries to open the Help page a couple of times and crashes with a general unknown error.
It seems that it might be running out of or misusing it's available resources as it doesn’t crash on the same part of the script or the same image each time but usually after a running for a long time.
Is there a limit to the number of times Photoshop can perform certain actions such as opening or saving files? Is there any way to close and reopen Photoshop at set times in a script to allow it to free up the resources and not trip up over itself?
I can provide a copy of the script to look through but I warn you it's fairly long and relies on some external psd files to run.
Win10 10.0.17134 Build 17134
32GB Ram
Photoshop CC 20.0.4
