Share

Share[expr]

changes the way expr is stored internally, to try and minimize the amount of memory used.

Share[]

tries to minimize the memory used to store all expressions.

Details

  • Share works by sharing the storage of common subexpressions between different parts of an expression, or different expressions.
  • Using Share will never affect the results you get from the Wolfram Language. It may, however, reduce the amount of memory used, and in many cases also the amount of time taken.
  • Share returns the number of bytes freed as a result of sharing, as determined by MemoryInUse.

Examples

Basic Examples  (2)

Try to minimize memory used in all expressions:

Use shared memory for parts of an expression that are the same:

This is effectively the same as creating the expression using shared parts:

For this expression, Share is not able to save any more memory:

Wolfram Research (1988), Share, Wolfram Language function, https://reference.wolfram.com/language/ref/Share.html.

Text

Wolfram Research (1988), Share, Wolfram Language function, https://reference.wolfram.com/language/ref/Share.html.

CMS

Wolfram Language. 1988. "Share." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Share.html.

APA

Wolfram Language. (1988). Share. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Share.html

BibTeX

@misc{reference.wolfram_2023_share, author="Wolfram Research", title="{Share}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Share.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_share, organization={Wolfram Research}, title={Share}, year={1988}, url={https://reference.wolfram.com/language/ref/Share.html}, note=[Accessed: 19-March-2024 ]}