MathGroup Archive 1991

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

Search the Archive

Mma 1.2 memory management bug (not in 2.0)

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Mma 1.2 memory management bug (not in 2.0)
  • From: Pekka Janhunen <pjanhune at finsun.csc.fi>
  • Date: Mon, 21 Oct 91 09:46:18 +0200

Consider the following:

Mathematica (sun4) 1.2 (June 13, 1990) [With pre-loaded data]
by S. Wolfram, D. Grayson, R. Maeder, H. Cejtin,
   S. Omohundro, D. Ballman and J. Keiper
with I. Rivin and D. Withoff
Copyright 1988,1989,1990 Wolfram Research Inc.
 -- Terminal graphics initialized --

In[1]:= A=Table[Random[],{10},{10}];

In[2]:= Do[Inverse[A]; Print[MemoryInUse[]],{5}]
1410600
1411456
1412312
1413168
1414024

It appears to be that Inverse in Mathematica (1.2) leaves one internal copy
of the matrix hanging in memory, never freeing it. No user command,
Clear, ClearAll, Remove etc. can return the memory, to my experience.
Similarly behave also LinearSolve and Eigenvalues. This bug appears
only if the matrices are numerical (floating point). Functions Det and
SingularValues, on the other hand, behave correctly! This provides a
way out of the dilemma, at least for the Inverse case, namely we can
also find the matrix if we first calculate its singular value
decomposition:

In[3]:= inverse[A_]:=\
        Block[{u,w,v},{u,w,v}=SingularValues[A]; \
        Conjugate[Transpose[v]].DiagonalMatrix[1/w].u]

In[4]:= Do[inverse[A]; Print[MemoryInUse[]],{5}]
1419832
1419832
1419832
1419832
1419832

Now the memory does not grow a single byte. We do not yet (...) have
2.0, so if someone out there could check this with the new version.
This bug was noticed when one program, after running for 24 hours
on a Sun SPARC, ended up using 32 megabytes virtual memory. When
the substitution Inverse->inverse was made, the memory remained
under 6 megabytes. The increment of memory when Inverse is used
is very nearly equal to the floating point (C language) internal
representation of the matrix.

Pekka Janhunen
Finnish Meteorological Institute
Geophysics Department
email: pjanhune at finsun.csc.fi

P.S. Steve Christensen pointed out that the bug does NOT exist 
on Mma 2.0. The memory does not grow, whether one uses Inverse
or SingularValues. Thanks for S.C. for providing this information.



  • Prev by Date: Question about x_h
  • Next by Date: Mathematica class
  • Previous by thread: Mma 1.2 memory management bug (not in 2.0)
  • Next by thread: Mathematica: A Practical Approach (A Workshop)