MathGroup Archive 2006

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

Search the Archive

Memory Leak

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66811] Memory Leak
  • From: Lawrence Weintraub <lcw at astro.caltech.edu>
  • Date: Wed, 31 May 2006 06:31:07 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I've looked through the many comments on memory leaks and cannot solve my 
montonically increasing memory usage.  Setting $HistoryLength=0 doesn't 
help.  Using ClearCache[] doesn't do much either.  If anyone could help 
me, I'd be very grateful.  My (simplified) code is:

$HistoryLength=0;

memEater[smin_?Positive, smax_, sigma_?Positive, fluxes_] :=
     Module[{s, snew, snoise, result, noisevec, bigvec, ds = 0.01, likes,
         likeFunc,t},
      snMin = -40.*sigma;
      s = Range[Min[fluxes], Max[fluxes], ds];
      snoise = Range[snMin, -snMin, ds];
      noisevec = Exp[-(Range[snMin, -snMin, ds])^2];
      bigvec = ListConvolve[noisevec, Abs[s], {1, -1}, 0.0];
      snew = Range[s[[1]] + snoise[[1]],s[[-1]] + snoise[[-1]],ds];
      s =.;
      snoise =.; noisevec =.;
      t = Transpose[{snew, bigvec}];
      likeFunc = Interpolation[t];
      t =.; snew =.; bigvec =.;
      likes = likeFunc[#] & /@ fluxes;
      Clear["likeFunc$*"];
      result = If[Min[likes] < 0, -10.*Length[fluxes],
                  Plus @@ (Log[#] & /@ likes)]; likes =.;
      result];

When I run this:

ct = 0; mem0 = MemoryInUse[];
fluxes = Table[Random[]*35. - 5., {i, 1000}];
Do[mem = MemoryInUse[];
res = memEater[.2, 30., 0.3, fluxes];
Print[MemoryInUse[] - mem0];
Developer`ClearCache[];
Print[MemoryInUse[] - mem0];,{10}];

From In[82]:=
46080

From In[82]:=
46080

From In[82]:=
93320

From In[82]:=
93320

From In[82]:=
140560

From In[82]:=
140560

From In[82]:=
187800

From In[82]:=
187800

From In[82]:=
235040

From In[82]:=
235040

From In[82]:=
282280

From In[82]:=
282280

From In[82]:=
329520

From In[82]:=
329520

From In[82]:=
376760

From In[82]:=
376760

From In[82]:=
424000

From In[82]:=
424000

From In[82]:=
471240

From In[82]:=
471240



Larry Weintraub
Astrophysics
California Institute of Technology
1200 E California Blvd
MC 105-24
Pasadena, CA 91125

lcw at astro.caltech.edu
626-395-4051


  • Prev by Date: Re: Mixed tensors as arguments of compiled functions
  • Next by Date: How to display non contiguous datasets
  • Previous by thread: Beginner--getting rid of dot products with zero
  • Next by thread: How to display non contiguous datasets