Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14451

Re: Simple program leaking memory - why?

From Joe Gwinn <joegwinn@comcast.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Simple program leaking memory - why?
Date 2013-05-08 08:10 +0000
Message-ID <kmd1ag$4km$1@smc.vnet.net> (permalink)
References <kmabu3$qdj$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


In article <kmabu3$qdj$1@smc.vnet.net>, <gredner@gmail.com> wrote:

> Hi folks,
> 
> I'm fighting an issue in which a simple Mathematica program to export a bunch
> of plots is leaking a huge amount of memory - enough to exhaust the 12G
> available on my machine.  The problem is, it looks like the program should
> run in bounded memory!  A simplified version of my code which demonstrates
> the problem follows:
> 
> ====================
> n = 10000;
> (* just some bogus data *)
> makeData[_] := Table[{{x, y} = RandomReal[{-3, 3}, {2}], {y, -x}}, {200}];
> data = Array[makeData, n];
> ParallelMap[
>   Export[
>     "movie-" <> IntegerString[#, 10, 4] <> ".png",
>     ListVectorPlot[data[[#]]]] &,
>   Range[1, n]];
> ====================
> 
> The problem occurs whether the loop is Map or Do, Parallel- or not.  It
> occurs in Mathematica 8 and 9, both under Linux.
> 
> The amount of memory leaked per frame is considerable - approximately .6 MB
> in my tests.  I don't see where it could be going, unless Export is caching
> every byte which passes through it!
> 
> I've also asked this question on stackexchange [1] but so far nobody has a
> clue.
> 
> Thanks,
> -Gabe
> 
> [1] http://mathematica.stackexchange.com/questions/24461/why-does-this-simple-program-leak-memory
> 

Mathematica keeps all In and Out cells, and this can look like a leak. 
Set $HistoryLength to zero and see if that helps.

There was a thread on this in September 2012 titled "Kernel exits (for
lack of memory)" or just "Kernel exits".

Joe Gwinn

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Simple program leaking memory - why? gredner@gmail.com - 2013-05-07 07:53 +0000
  Re: Simple program leaking memory - why? Joe Gwinn <joegwinn@comcast.net> - 2013-05-08 08:10 +0000
    Re: Simple program leaking memory - why? Gabriel Redner <gredner@gmail.com> - 2013-05-09 07:56 +0000
      Re: Simple program leaking memory - why? Joe Gwinn <joegwinn@comcast.net> - 2013-05-11 06:27 +0000
  Re: Simple program leaking memory - why? Roland Franzius <roland.franzius@uos.de> - 2013-05-13 07:47 +0000

csiph-web