Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: What Happens to Garbage in Mathematica?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43940] Re: What Happens to Garbage in Mathematica?
  • From: Olaf Rogalsky <olaf.rogalsky at theorie1.physik.uni-erlangen.de>
  • Date: Tue, 14 Oct 2003 01:07:36 -0400 (EDT)
  • References: <bm84s2$fug$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"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.

Olaf



In[1]:= MemoryInUse[]
        a=Table[n,{n,10^7}];
        MemoryInUse[]
Out[1]= 2299376
Out[3]= 42302168

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

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

In[10]:= Out[4]=.;
         MemoryInUse[]
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 theorie1.physik.uni-erlangen.de  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?