Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: memory release problem in mathematica6.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83321] Re: memory release problem in mathematica6.0
  • From: Ulvi Yurtsever <a at b.c>
  • Date: Sat, 17 Nov 2007 05:28:15 -0500 (EST)
  • Organization: Your Company
  • References: <fhegac$m08$1@smc.vnet.net> <fhh7qq$90c$1@smc.vnet.net>

Yaroslav Bulatov <yaroslavvb at gmail.com> wrote in news:fhh7qq$90c$1
@smc.vnet.net:

> I confirm this behavior. The following line works the first few times,
> but the memory isn't released with "Clear[A]" and after a few times
> kernel quits with "out of memory" message
> 
> A = RandomInteger[{1}, 100000000]; Clear[A]
> 
> On Nov 14, 1:49 am, jack <giaber... at gmail.com> wrote:
>> Hi all,
>> When i define large data structures, for example an array  "A" of
>> million  of elements that occupy some  hundreds of MB of physical
>> memory,when i clear it, with Clear[A] memory isn' t released by
>> operating system. I' ve tried both on windows and linux.
>> The result of MemoryInUse[] command of mathematica but the physical
>> memory reported by the system monitor isn't released.
>> I' ve tried also ClearSystemCache[] but with no result.
>> Am i missing something?

Even though you are clearing the variable, the ouput
from the operation, which is just as big, is still
stored in memory and cannot be cleared (even when
the output is suppressed with ; ).

To prevent this, use None after the assignment to prevent
the output from being stored in memory:


In[2]:= MemoryInUse[]

Out[2]= 6547536

In[3]:= a = Table[Random[], {3333}, {3333}];

In[4]:= MemoryInUse[]

Out[4]= 95422024

In[5]:= Clear[a]

In[6]:= MemoryInUse[]

Out[6]= 95422872


When "None" is used, Clear[a] successfully frees the memory:


In[1]:= MemoryInUse[]

Out[1]= 5810120

In[2]:= a = Table[Random[], {3333}, {3333}]; None

Out[2]= None

In[3]:= MemoryInUse[]

Out[3]= 95421592

In[4]:= Clear[a]

In[5]:= MemoryInUse[]

Out[5]= 6551232



Ulvi


  • Prev by Date: Re: Get list of function variables?
  • Next by Date: Re: Basic Locator question in a Manipulate...
  • Previous by thread: Re: memory release problem in mathematica6.0
  • Next by thread: Re: memory release problem in mathematica6.0