MathGroup Archive 2003

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

Search the Archive

Re: What Happens to Garbage in Mathematica?

  • To: mathgroup at
  • Subject: [mg43940] Re: What Happens to Garbage in Mathematica?
  • From: Olaf Rogalsky <olaf.rogalsky at>
  • Date: Tue, 14 Oct 2003 01:07:36 -0400 (EDT)
  • References: <bm84s2$fug$>
  • Sender: owner-wri-mathgroup at

"Steven T. Hatton" wrote:
> What happens to the alocated memory of objects such as graphics primatives
> when their variable are assigned new values?  For example, suppose I have a
> thousand pairs of triple which I use to create a thousand Line objects. If
> I then change the values of all the tripples, and create new Lines
> assigning them to the same variables I used to store the original Lines,
> what happens to the memory that held the original lines?

Mathematica "reference counts" every data object. The reference count of 
an object A is the number of other objects, which reference A.
In the example below, the created table is referenced 4 times: One
reference from the symbols a and b, and one reference from Out[2] and Out[4].
If the reference count of an object drops to 0, the memory may be reclaimed
by Mathematica. But note, the freed memory is not given back to the operating
system, but only marked for reuse by Mathematica.


In[1]:= MemoryInUse[]
Out[1]= 2299376
Out[3]= 42302168

In[4]:= b=a;
Out[5]= 42303536

In[6]:= Unprotect[Out];
        a=.; b=.; Out[2]=.;
Out[9]= 42310416

In[10]:= Out[4]=.;
Out[11]= 2311576
I Dr. Olaf Rogalsky                         Institut f. Theo. Physik I I
I Tel.: 09131 8528440                       Univ. Erlangen-Nuernberg   I
I Fax.: 09131 8528444                       Staudtstrasse 7 B3         I
I rogalsky at  D-91058 Erlangen           I

  • Prev by Date: Re: Re: negative pattern matching anyone?
  • Next by Date: Integration
  • Previous by thread: Re: What Happens to Garbage in Mathematica?
  • Next by thread: Re: What Happens to Garbage in Mathematica?