Share
Usage
• Share[expr] 改变expr的内部存放方式以优化所使用的内存.
• Share[ ] 优化用作存放所有表达式的内存.
Notes
• Share 通过共享一个表达式不同部分之间或不同表达式之间普通子表达式的存放空间来进行工作. • 使用Share将不影响你从Mathematica中获得的结果.但它可能减少所使用的内存量,并且在很多情形下也能减少所花费的时间.
Further Examples
Here is the amount of memory in use at the time this expression was evaluated.
In[1]:=
|
Out[1]=
|
This creates a very large data structure of interpolating functions.
In[2]:=
|
You can see that almost 3/4-megabyte of memory has been taken up in computing and then storing this result.
In[3]:=
|
Out[3]=
|
When you run Share, it reports back how much memory was recovered.
In[4]:=
|
Out[4]=
|
Here is the amount of memory in use after running Share.
In[5]:=
|
Out[5]=
|
|