• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Memory leak accessing 'paragraphs', 'characters' properties

New Here ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

I do work that involves batch processing of several hundreds or even thousands of EPS illustrations. During one round of processing, I started getting "Out of memory" errors. Windows Task Manager indeed showed Illustrator taking up all available memory. With some sleuthing, I pinpointed the problem to a call to the 'paragraphs' property of TextFrameItem.

The code looks like the following:

for (var i = 0; i < fileList.length; i++) {

     var aiDoc = open(new File(fileList));

     // Do some stuff

     // ...

   

     // Check paragraphs

     for (var j = 0; j < aiDoc.textFrames.length; j++) {

          var pObj = aiDoc.textFrames.paragraphs;

          for (...) {

               var p = pObj;

               // Do some paragraph stuff

          }

     }

}

If I eliminate the part that accesses 'paragraphs', so leak occurs. But even just adding the var pObj = ... statement immediately sent Illustrator into a memory feeding frenzy.

Does anyone have any experience with this? Any mitigations? Does Adobe have a bug reporting system?

It occurs on both CS6 and CC versions of Illustrator. As in the title, the 'characters' property seems to have a similar leaking effect.

Thanks!

TOPICS
Scripting

Views

395

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

memory issues are a problem indeed.

does processing 1 file gets illustrator into a memory feeding frenzy? or does it only happen when you process thousands of files?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

That's a good question. For the processing in question, doing one file doesn't seem to affect memory much. Most files have on the order of 10s (maybe as many as 100) text frames, and each one's paragraph property is accessed. But looking at Task Manager during this process doesn't show any particularly large increase in memory allocation.

What happens is:

  1. File is opened, and a few megabytes of memory are allocated.
  2. Processing - no significant change to the amount of memory.
  3. File is closed, but allocated memory decreases slightly.

Normally, step 3 returns the amount of memory allocated to Illustrator to roughly where it was before the file was opened.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

ok, great. All variables get saved to a single scripting session so they accumulate and choke illustrator overtime. It is recommended to restart illustrator often to restore the memory cache. Illustrator is not able to process thousands of files, Adobe recommends processing about 500 files on Windows before needing to restart. If you're on mac, I think the limit is higher but in real life illustrator might crash processing less than 100 complicated files or it might easily process over 1000 files without issues if the files are simple. It totally depends on what's on the files. Trial an error to find a safe number of files to process.

so, you can limit the number of files to process in a single session. Restart often.

some have suggested processing the files and leave them open, then at the end close them all.

also, I've found that taking your variable declarations out of your loops helps a lot

instead of

for (var a=0.....) {

    var docRef = .....

}

do this

var docRef;

for (var a=0...) {

    docRef = .....

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 04, 2019 Jul 04, 2019

Copy link to clipboard

Copied

Thanks for your reply.

In practice, dividing up the workload is exactly what we do, but obviously this is not the ideal solution.

As for leaving files open, probably not practical with several hundred. Also, the largest memory allocations occurred when opening the files, so not closing them would exacerbate the problem in my case.

As I implied, the only scripts where we encounter any actual problems are those that access paragraphs and characters properties (though there may be more, of course).

Though Illustrator scripting has gotten better over the years, it's obvious that it's not Adobe's priority. Just look at all the typos in the JavaScript documentation! (Which, I would be willing to offer feedback if I knew whom to contact )

Thanks again, though. Again if there's a bug reporting mechanism I'd love to know about it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2019 Jul 04, 2019

Copy link to clipboard

Copied

there is one, post your queries here

Adobe Illustrator Feedback

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

LATEST

One workaround to this issue I found is that while

.paragraphs[k].lines.length

leaks, the following do not

.paragraphs.length
.paragraphs[k].contents

for my use case, I was able to use these instead.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines