Re: Memory Leak with KSubsets?
- To: mathgroup at smc.vnet.net
 - Subject: [mg38352] Re: [mg38275] Memory Leak with KSubsets?
 - From: Kirk Reinholtz <kirk.reinholtz at jpl.nasa.gov>
 - Date: Thu, 12 Dec 2002 01:37:42 -0500 (EST)
 - References: <200212100917.EAA14948@smc.vnet.net>
 - Sender: owner-wri-mathgroup at wolfram.com
 
I observed the same thing, except I was computing closures on a large
number of graphs, again using combinatorica.  I examined the
combinatorica code and couldn't find any place where it was holding on
to references internally, but none the less I fixed it by modifying
their algorithms for my purposes.  What I did, in particular, was
instead of maintaining the several representations of the graph that
combinatorica passes around, I just used adjacency list.
I never did prove what's going on, but my guess is that there is some
results caching in Mathematica (that is suggested by the graph of
MemoryInUse[] as I did repeated closures: it had a distinct sawtooth
superimposed on it).  Perhaps Mathematica doesn't clear the cache aggressively
enough, maybe having a long chain of references causes it to loose track
of the actual size of something, or it doesn't examine the whole chain
each time is does a cache sweep, or ...
Arny wrote:
> 
> Dearest group
> 
> Has anyone noticed this before?  I would like to use KSubsets and
> RandomKSubsets a few million times in a proggy, but after executing it a few
> thousand times Mathematica crashes, running out of memory.  Watching my Taskman (Win
> 2K, Mathematica 4.1) we see a constant increase in memory used, until its all soaked
> up.  I have this problem with both the Combinatorica.m that shipped with
> Mathematica, and the new one that has been written, which I believe is now the one
> in Mathematica 4.2.  I am not really sure what it means to 'leak memory', but this
> seems to fit the bill.
> 
> Here is a crashing-demo.  Executing "memorySwallower[3,100]", for example,
> repeatedly just soaks up more and more memory.  Pourquoi?  I believe the
> same thing happens if I use KSubsets also.
> 
> In[1]:=
> MemoryInUse[]
> Get["DiscreteMath`Combinatorica`"]
> MemoryInUse[]
> Out[1]=
> 1398624
> Out[3]=
> 1956536
> 
> memorySwallower[S_,n_]:=
>   Module[{data,subsamples},Print[ToString[MemoryInUse[]]];
>     Table[data=Table[{i,j},{i,1000},{j,1+m}];
>       subsamples=Table[RandomKSubset[data,S],{100}],{m,n}];
>     Print[ToString[MemoryInUse[]]]]
> 
> memorySwallower[3,100]
> 
> 15497936
> 29833672
> 
> Regards,
> B
> _____________________________
>   Bernard Gress
>   Department of Economics
>   University of California, Riverside
>   1150 University Ave.
>   Riverside, CA 92521-0247
>   Fax: (909) 787-5685
>   Phone: (909) 778 9813
>   BGRESSatMAILdotUCRdotEDU
>   ICQ: 9083461
>   http://www.economics.ucr.edu/people/candidates.html
- References:
- Memory Leak with KSubsets?
- From: "Arny" <someone@somewhere.sometime>
 
 
 - Memory Leak with KSubsets?