Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Tuning & Debugging > Memory Measurement & Optimization > Share >
Mathematica > Systems Interfaces & Deployment > Mathematica Sessions > Mathematica Session Information > Memory Measurement & Optimization > Share >

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.
  • 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 Mathematica. It may, however, reduce the amount of memory used, and in many cases also the amount of time taken.
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:
Try to minimize memory used in all expressions:
In[1]:=
Click for copyable input
Out[1]=
 
Use shared memory for parts of an expression that are the same:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
This is effectively the same as creating the expression using shared parts:
In[3]:=
Click for copyable input
Out[3]=
For this expression, Share is not able to save any more memory:
In[4]:=
Click for copyable input
Out[4]=
New in 1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF