MathGroup Archive 2003

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

Search the Archive

Re: Compile + Module =X> Memory Leak; Outer & Compile =>Memory Leak

  • To: mathgroup at
  • Subject: [mg40033] Re: Compile + Module =X> Memory Leak; Outer & Compile =>Memory Leak
  • From: Bern <bgress at>
  • Date: Sun, 16 Mar 2003 02:48:11 -0500 (EST)
  • Organization: University of California, Riverside
  • References: <b4mocf$inm$> <b4pdj8$b8r$>
  • Sender: owner-wri-mathgroup at

Dear Mr. Kuska,

Thanks for this help.  I was not however able to get your change of 
Module to Block to work, presumably because you are asking Compile to 
work with a global variable, which it won't do.

After some experimentation I discovered that you are correct, it isn't 
the fault of either Block, Module, or even With, all of which can be 
used here.  The real problem is Outer.  Redefining the first Sum to use 
Dot and Transpose, instead of Outer, fixed the problem completely.  No 
more memory leak.

So my new hypothesis is that Outer + Compile causes a Memory Leak.  This 
is under Mathematica 4.2 & Windows2K.  Does Wolfram monitor these posts?



> The problem has nothing to do with Module[] or Block[] because
> the memory is allmost constant with the uncompiled...
> u;
> w = Compile[{{XJ, _Real, 1}, {XX, _Real, 1}, {nj, _Integer}, {ni,
> _Integer}}, 
>     Block[{p}, u = Table[Random[], {i, ni}, {j, nj}, {p, 0, 1}]; 
>       Table[Last[
>           Inverse[Sum[
>                 Outer[Times, u[[i, j]], u[[i, j]]*(XX[[i]] -
> XJ[[j]])^2], {i, 
>                   1, ni}]].Sum[
>               Table[u[[i, j]]*XX[[i]]*(XX[[i]] - XJ[[j]])^2], {i, 1, 
>                 ni}]], {j, nj}]], {{u, _Real, 3}}]

> that does not change the memory *and* is significant faster than the
> original function with the local u.

> Regards
>   Jens

  • Prev by Date: Re: Right-click'd BMP vs. exported BMP
  • Next by Date: Re: Re: Don't understand Plot behavior
  • Previous by thread: Re: Odd memory behavior, and uncontrollable memory growth
  • Next by thread: Re: Compile + Module =X> Memory Leak; Outer & Compile =>Memory Leak