MathGroup Archive 2010

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

Search the Archive

Strange memory behavoir of Norm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109094] Strange memory behavoir of Norm
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Mon, 12 Apr 2010 23:00:49 -0400 (EDT)

Hi,

a user of another forum brought my attention to a memory leak which I
cannot explain. For real-valued numbers x1, x2 and x3 the following is
the same

Norm[{x1, x2, x3}]
Norm[{{x1}, {x2}, {x3}}]

Can someone confirm and maybe explain the following behavoir? I checked
it on Linux and OSX with Mathematica 7.

usedmema = MemoryInUse[];
Block[{a = {1., 1., 1.}},
   Nest[Norm[a] &, Null, 10^6];
   ];
(MemoryInUse[] - usedmema)/2^20.

gives here 0.00259399 while

usedmema = MemoryInUse[];
Block[{a = {{1.}, {1.}, {1.}}},
   Nest[Norm[a] &, Null, 10^6];
   ];
(MemoryInUse[] - usedmema)/2^20.

gives 122.075 MB of used memory. Expanding the definition of  
Norm[{{x1}, {x2}, {x3}}]
and testing this

usedmema = MemoryInUse[];
Block[{a = {1., 1., 1.}},
   Nest[Sqrt[
       a[[1]]*Conjugate[a[[1]]] + a[[2]]*Conjugate[a[[2]]] +
        a[[3]]*Conjugate[a[[3]]]] &, Null, 10^6];
   ];
(MemoryInUse[] - usedmema)/2^20.

gives no memory leak with 0.00299072MB.

Any ideas?

Cheers
Patrick


  • Prev by Date: Re: beginner question about syntax
  • Next by Date: Re: Support for PlotLegend in DateListPlot
  • Previous by thread: Can you communicate about Mathematica?
  • Next by thread: Re: Support for PlotLegend in DateListPlot