Skip to main content
Inspiring
August 13, 2015
Question

Memory leak when processing many AEP files, can I fix?

  • August 13, 2015
  • 2 replies
  • 882 views

I previously posted this in the SDK forum but then saw that this forum exists so this may be a better place to put it...

I deal with a lot of users and a relatively large data set. I have an automated process that churns through files to do stuff, the simplest of which is one that just opens every AEP file in a directory hierarchy and saves it, so that subsequent processes (and the users themselves) don't need to deal with manually upgrading files after a version bump in After Effects.

I generate a script with a batch file and then launch AfterFX.com -m -r the_script.jsx.

After Effects leaks memory like mad. My computer gets slower and slower as this list of items is processed and I'm wondering if there's something else I should be doing to get After Effects to reset its memory usage, something a little cleaner than just app.quit()'ing after every 10 files or so. (Which I'd like to avoid because at present everything works well enough in a Windows batch file.)


Here's what I'm doing, filenames changed to protect the guilty but otherwise this is the sort of script that I run.

function Resave(filename) {

  try {

    var file=new File(filename);

    app.open(file);

    app.project.save(file);

  }

  catch(err) {

    alert('Error while processing: ' + filename + '\n\n' + err.message);

  }

  app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);

}

app.saveProjectOnCrash = false;

app.beginSuppressDialogs();

Resave('XXXXXXXXXXXXXXXXXXXXXX\\XXXXXXXXXXXXXXXXXXXX.aep');

Resave('XXXXXXXXXXXX\\XXXXXXXXXXXX.aep');

Resave('XXXXXXXX\\XXXXXXXX.aep');

Resave('XXXXXXXXXXXX\\XXXXXXXXXXX.aep');

// 100+ more lines of this

Resave('XXX\\XXX.aep');

app.endSuppressDialogs(false);

app.quit();

This topic has been closed for replies.

2 replies

Legend
October 29, 2015

I've encountered this before.  It may be happening due to layer caching.  As your script makes changes to your project, AE will cache changes in memory and you perceive it as a "leak". I know the example script you give doesn't change anything directly to layers, but still, it could be the case.

Have you tried to disable layer caching and trying again?

To disable layer caching, hold SHIFT down while you open up any of After Effects' preferences.   You'll see a tab called "Secret" on the list on the left.  Click that and then check the "Disable Layer Cache" setting.  And then change the integer in "Purge Every __ Frames During Make Movie"  to 1. 

I'm not claiming that this will fix, but I do know that as scripts process the files, and layer caching is enabled it can slow AE down in automation processes.

Hope this helps!

—Arie

Dan Ebberts
Community Expert
Community Expert
August 13, 2015

I don't know that this will help, but have you tried app.purge(PurgeTarget.ALL_CACHES);  ?

Dan

Inspiring
October 27, 2015

Yeah, I currently have that right after the app.project.close() call.

Legend
October 27, 2015

I generate a script with a batch file and then launch AfterFX.com -m -r the_script.jsx.

Even though you are reusing AE (-r), is it possible that a new unique instance of AE is launched every time by chance? That would definitely eat resources up very fast.