Skip to main content
Inspiring
January 18, 2018
Answered

Purging (Undo?) Cache

  • January 18, 2018
  • 1 reply
  • 1534 views

Hi!

I'm using scripts scripts to simplify repeditive tasks on complex files. My problem is that Illustrator is runing out of memory after a while and crashes after a while and to prevent this every 30 minutes I need to:

pause the script.

save the file (this takes a while, it's a complex file)

open the file

start the script.

I think it's the Undo cache that's acculminating the RAM.

So to my question:

Is there any way to either disable undos, or via script, flush the undo cache now and then?

Thanks!

This topic has been closed for replies.
Correct answer Disposition_Dev

Depending upon what your script is doing it, and how it's doing it, it's unlikely that the undo cache is filling up or causing an issue. Most scripting commands do not create an undo state. Therefore, you could run a script that executes 1000 commands, and still only have one undo point. Some commands do create undo points (and i've made it a mission of mine to try to avoid these whenever possible), however. the app.executeMenuCommand() method creates an undo point in most cases. And also duplicating any artwork from one file to another creates an undo point.

Memory leakage has been a problem for a while with scripting illustrator. Some methods for preventing, or at least minimizing, these issues are as follows.. Perhaps some others will jump in and share their successes in this area as well.

  • when batching files, you should open all the necessary files first, then execute your script's functionality, then close all of your files.
    • something about opening/processing/closing files one after the other exacerbates the memory issue.
  • declare your variables outside of loops.

I thought my list was going to be longer... anyway.. Taking these steps has had a profound effect on my workflow. Hopefully they'll help you as well.

If you want to try out the undo state thing, there's a setting in your Illustrator Preferences under the performance tab where you can change the number of undo states to keep. however, i think this fact nullifies your initial suspicion. there is a finite amount of undo states that you can keep.

1 reply

Disposition_Dev
Disposition_DevCorrect answer
Legend
January 18, 2018

Depending upon what your script is doing it, and how it's doing it, it's unlikely that the undo cache is filling up or causing an issue. Most scripting commands do not create an undo state. Therefore, you could run a script that executes 1000 commands, and still only have one undo point. Some commands do create undo points (and i've made it a mission of mine to try to avoid these whenever possible), however. the app.executeMenuCommand() method creates an undo point in most cases. And also duplicating any artwork from one file to another creates an undo point.

Memory leakage has been a problem for a while with scripting illustrator. Some methods for preventing, or at least minimizing, these issues are as follows.. Perhaps some others will jump in and share their successes in this area as well.

  • when batching files, you should open all the necessary files first, then execute your script's functionality, then close all of your files.
    • something about opening/processing/closing files one after the other exacerbates the memory issue.
  • declare your variables outside of loops.

I thought my list was going to be longer... anyway.. Taking these steps has had a profound effect on my workflow. Hopefully they'll help you as well.

If you want to try out the undo state thing, there's a setting in your Illustrator Preferences under the performance tab where you can change the number of undo states to keep. however, i think this fact nullifies your initial suspicion. there is a finite amount of undo states that you can keep.

iLLMonkeyAuthor
Inspiring
January 18, 2018

Hmm now when you gave me some insights I wonder if it might not be the undos after all, since after all the processing, if I ctrl+z, it puts me back to the beginning. Never thought of it.

It's a bummer that I couldn't set undos to zero, 50 is the minimum value, and my script causes a crash after about 30 loops 32GB ram filled to the brim. A zero value would put those "undo" concerns at rest completely.

I'm not doing anything all to crazy with the script, in short just duplicating and moving around a complex group, cropping it a bit, repeat 200 times.

CarlosCanto
Community Expert
Community Expert
January 19, 2018

There's a chance you're not doing anything wrong, the usual suspect is Illustrator. Post your code, we might be able able to spot the issue if any.