In Mathematica, how can I make the best use of my system's memory?

In Mathematica, you can use ClearAll to recover memory associated with calculations you no longer need. For this to work, you must also remove your output history with Unprotect and Clear[Out].

Mathematica will use some amount of memory to start up:

 In[1]:= MemoryInUse[] Out[1]= 812448

If you create a large matrix (e.g., t) but suppress the output, and then check the memory again, you'll see the memory used increases:

 In[2]:= t = Table[Random[], {1000}, {1000}]; In[3]:= MemoryInUse[] Out[3]= 20843256

If you clear the variable (e.g., t) from memory, the memory used increases slightly again:

 In[4]:= Clear[t] In[5]:= MemoryInUse[] Out[5]= 20844712

However, if you also clear the output from memory, you reduce the memory used to nearly the minimal amount:

 In[6]:= Unprotect[Out] Out[6]= {Out} In[7]:= Clear[Out] In[8]:= Protect[Out] Out[8]= {Out} In[9]:= MemoryInUse[] Out[9]= 827120

For more, see At IU, what software packages does UITS Research Analytics support?

If you have questions about using statistical and mathematical software at Indiana University, contact Research Analytics. Research Analytics is located on the IU Bloomington campus at Woodburn Hall 200; staff are available for consultation Monday-Friday 9am-noon and by appointment.

Note:
For details about availability of UITS services during Thanksgiving break, see UITS Thanksgiving break support hours.

This is document adiv in the Knowledge Base.
Last modified on 2016-11-15 12:16:48.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.