MathGroup Archive 2002

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

Search the Archive

Re: Memory Problems and "shdw"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37980] Re: [mg37964] Memory Problems and "shdw"
  • From: Kirk Reinholtz <kirk.reinholtz at jpl.nasa.gov>
  • Date: Sat, 23 Nov 2002 19:15:04 -0500 (EST)
  • References: <200211220916.EAA05693@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

My experience has been that this happens when you accidently hold onto
something you no longer need: perhaps some list that grows with time, or
ever increasing number of symbols (which is easy to do using the f[x_]
:= f[x] = ... pattern).  Mathematica only releases memory objects when
there are no references to the object.  If you have a few suspect data
structures, you could watch ByteCount.  Or for bonus programming points
periodically capture the sizes of all data structures and look for
trends of growth in either the number of data elements, or the size of
particular ones.

Once you find the problem, consider algoithm changes, explicit remove[],
or scoping constructs to bound the lifetime of the offending elements.

I've also noticed that some packages exhibit interesting memory trends. 
For example, I was using Combinatorica on a large transitive closure
problem, and had unbounded memory growth, using more memory each time I
did a closure, even though I was careful to release all references to
the elements once I was done with each pass.  I never did figure out
why, but when I made simpler version of the algorithms it worked fine. 
But even then I noted memory would grow for a while then drop a lot,
suggesting there's some internal caching going on.

Hein H wrote:
> 
> I have written a large program in the Mathemetica language and I am
> having memory problems.  The MemoryInUse[] is growing at 10 Megs per
> hour when the program is running and I haven't figured out why.  Can
> anyone recommend a way to track down where the memory is used?  Right
> now I am using 2 methods to try to find the problem:
> 
> 1)  Print["memory = ", MemoryInUse[]] in several places.
> 
> 2)  sz[s_Symbol] := ByteCount[ DownValues[s]];
>     sz[x_]       := ByteCount[x];
>     Print[{sz[ToExpression[#]], #} & /@ Names[] // Sort];
> 
> Also, is there any way to suppress the "shdw" warning message?
> 
> Thanks,
> 
> Hein


  • Prev by Date: Setting Options Back to Default Values? (and other graphics queries)
  • Next by Date: Automatic Closing of Animation Graphics Cells
  • Previous by thread: Memory Problems and "shdw"
  • Next by thread: Possible Bug in Units2