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

Will memory usage change between field level and document level?

Participant ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Does writing all the code in each field, or writing a document-level function and writing it, change the overall processing speed of the document?

 

Does (1) and (2) below change the overall document processing speed? For example, suppose there are about 20 fields that use the same calculation. And suppose it's a bit longer code.

 

(1) Write the same code in all fields.
(2) Write a document level function and use it.

 

Obviously, (2) is the safest and easiest way to write code.

 

Is there any difference between (1) and (2) above?  Of particular interest is how PDF JavaScript uses memory.  I've heard that generally global functions use a lot of memory, so it's better not to use too much.

TOPICS
Acrobat SDK and JavaScript

Views

559

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

correct answers 1 Correct answer

Community Expert , Jun 07, 2020 Jun 07, 2020

I believe you read that uses of the "Global" object should be limited, because it can cause memory usage issues. This has nothing to do with functions.

 

Functions and JavaScript code in general have no greater or lessor affect on memory that depends on location. Now, if you put the same code in several different fields, this does take up more memory, but the amount is trival.

The actions the scripts perform however, can have a huge effect on memory. The JavaScript engine does not clean up unuse

...

Votes

Translate

Translate
Community Expert ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

"I've heard that generally global functions use a lot of memory, so it's better not to use too much."

Where have you heard or read this?

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
Participant ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

I'm sorry, but I don't remember where the page actually was. I read it on the page that describes JavaScript.

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 ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

I don't believe there's any difference at all in memory consumption, and of course not in "safety", whatever that means.

It's much better to use a doc-level script with a function that is called from the individual fields because if you need to edit the code you can just do it once and don't need to go field by field to edit 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
Participant ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

Thank you very much. I was relieved to hear 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 ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

I believe you read that uses of the "Global" object should be limited, because it can cause memory usage issues. This has nothing to do with functions.

 

Functions and JavaScript code in general have no greater or lessor affect on memory that depends on location. Now, if you put the same code in several different fields, this does take up more memory, but the amount is trival.

The actions the scripts perform however, can have a huge effect on memory. The JavaScript engine does not clean up unused objects quickly.  So if you write code that creates lots of new objects (variables) it can cause problems. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Participant ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

LATEST

Thank you very much. Your explanation was all I wanted to know. I learned a lot.

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