MathGroup Archive 2001

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

Search the Archive

Memory leak

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27868] Memory leak
  • From: "Carl K. Woll" <carlw at u.washington.edu>
  • Date: Thu, 22 Mar 2001 04:30:08 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi all,

I have recently come across the following command which leaks memory, 
and thought that it might be of interest to the Mathematica community. 
To check for memory leaks in a statement, I run the following commands:

Print[{MemoryInUse[],MaxMemoryUsed[]}];
Do[ statement;
    Print[{MemoryInUse[],MaxMemoryUsed[]}], {10}]

If statement has no memory leak, then each of the print statements above 
should be the same (except for the first couple). For a simple statement 
like 1+1 this is indeed the case. However, when using the Drop command 
with more than one sequence specified, each of the print statements 
increases by 32 bytes on my system, which is Mathematica 4.0 on Windows 
NT. For example,

Print[{MemoryInUse[],MaxMemoryUsed[]}];
Do[ Drop[{{1,2},{3,4}},-1,1];
    Print[{MemoryInUse[],MaxMemoryUsed[]}], {10}]

will demonstrate this memory leak. If only one sequence specification is 
given, like Drop[{{1,2},{3,4}},-1] then no memory leak occurs. Feel free 
to comment on whether this is an accurate gauge of a memory leak, and 
whether your system also experiences this leak.

Carl Woll
Physics Dept
U of Washington


  • Prev by Date: Re: Calling a remote kernel from an external program.
  • Next by Date: Announce: PNG Import/Export for Mathematica 4.x
  • Previous by thread: Re: Evaluating large polynomials over Z_p
  • Next by thread: Re: Memory leak