MathGroup Archive 1996

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

Search the Archive

Re: Out Of Memory

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3155] Re: Out Of Memory
  • From: withoff (David Withoff)
  • Date: Fri, 9 Feb 1996 03:01:03 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

In article <4f960m$dp3 at dragonfly.wolfram.com> Rob Carscadden  
<carscadd at pps.pubpol.duke.edu> writes:
> I'm trying to take the determinant of a 6 by 6 Jacobian, but I keep 
> getting an "Out of Memory" error. Mathematica grinds away, but finally 
> just stops. Mathematica is the only thing running in Windows3.1. My 
> machine grinds away with SAS no problem. Is there some way to help 
> mathematica (increase the kernel maybe?)? I don't want to take this 
> matrix apart and find the det by minors, so please don't suggest that 
> approach.
> 
> Thanks for the help.
> Rob

In the absence of any special cancellations, the expanded determinant
of a 6 x 6 symbolic matrix will have 6! terms in it, each a product
of 6 matrix elements.  If each matrix element uses  1 kB of memory,
that's about four megabytes of memory.  You probably won't be able
to store very many determinants like that without running out of memory.

I saw your example, though, (I think this is the example that
you sent to technical support, support at wri.com), and from your
example I don't believe that this is the problem.  In your example,
I think your computer is running out of memory while formatting
the result.

This is a common problem, and is not peculiar to Mathematica.  There
are many examples where the computer will have plenty of memory to
store a result, but will not have enough memory to display it.

In some situations, for example, if you paste 10 copies of the
same page of text in a word processor, the word processor will
only store one copy of the text, and will set up pointers to that
one copy.  If you print the document out on a printer, the printer
will produce 10 separate copies of the same page, effectively using
10 times as much space as was needed to store the same information
as is stored in the computer.  The technical term for this is
"sharing".  The computer shares the single copy of the information
between several places where it is needed.

Another consideration is that displayed results are often larger
than stored results even when there is only one copy.  For example,
a double-precision floating-point machine number is typically stored
in 8 bytes of memory, but if you display a number like

    1.234567890123456e-297

on your computer screen, 22 bytes of memory will be used to store
the 22 characters in the output.  Even more drastic memory requirements
come up in formatting more complex output, such as formatting
elaborate algebraic expressions.  It is not uncommon to use 10 or
20 times as much memory to format a result as is required to store it.

In Mathematica, you can use PrintForm to get a rough estimate of
the amount of memory that will be required to format an expression.
Here, for example, is a simple expression that is stored using
about 260 bytes of memory.

In[1]:= expr = Expand[(Sqrt[Sin[x]] + 1)^2]/2

        1 + 2 Sqrt[Sin[x]] + Sin[x]
Out[1]= ---------------------------
                     2

In[2]:= ByteCount[expr]

Out[2]= 26O

Over 7 times that amount of memory is used to display the result.

In[3]:= ByteCount[PrintForm[expr]]

Out[3]= 1900

Dave Withoff
Research and Development
Wolfram Research

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: [Q] Programming & "Not Floating Point Number" Error
  • Next by Date: Wave Equation
  • Previous by thread: Out Of Memory
  • Next by thread: MathSource CD for sale