How to free memory?
- To: mathgroup at smc.vnet.net
- Subject: [mg59750] How to free memory?
- From: "Wonseok Shin" <wssaca at gmail.com>
- Date: Fri, 19 Aug 2005 04:32:49 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Dear all, First of all, I'm using Mathematica 5.1 for Mac. I searched this news group and saw that many of us are suffering from short of memory while using Mathematica, but I failed to find a solution. Let's do a small experiment. -------------------------------- In[1]:= MemoryInUse[] Out[1]= 2908112 In[2]:= f[x_]:=x^2 In[3]:= MemoryInUse[] Out[3]= 2910344 (* Defining f[x] spends a little memory. *) In[4]:= data = Table[f[i], {i, 3 * 10^6}]; In[5]:= MemoryInUse[] Out[5]= 120499576 (* Huge increase in the memory in use!! *) In[6]:= data=.; Clear[data]; Remove[data]; (* Tried all clearing methods that I know. *) In[7]:= MemoryInUse[] Out[7]= 120501008 (* None of clearing methods frees the memory allocated to data. *) -------------------------------- The only way to free the memory allocated to data is killing the kernel from the menu command "Kernel > Quit Kernel > Local". Is it really true that there is no way to free the memory? Let's think about this situation. When we write a long program with Mathematica, we define several functions. Suppose that I'm finished with writing functions and going to apply them to data. We may do some experiment with data to see if functions work well. But unfortunately we always confront bugs. In this case we may want to fix bugs and to run functions again. But since there is no way to free memory, Mathematica finally eats up all free memory. After then Mathematica seems to use a virtual memory - Disk I/O suddely increases - and all calculations become extremely slow. When this happens, the only thing I can do is to abort the current evaluation and quit kernel. In conclusion, the need for freeing momory arises very frequently in the process of program development. At least for me, this is what happens every ten minutes because I deal with large matrices. And I heard that another system doesn't show this kind of problem. So recently I'm seriously considering changing the tools from Mathematica to others. How does Wolfram cope with this problem? I think there should be a solution!
- Follow-Ups:
- Re: How to free memory?
- From: ggroup@sarj.ca
- Re: How to free memory?