 
 
 
 
 
 
Re: Garbage collection problem
- To: mathgroup at smc.vnet.net
- Subject: [mg51953] Re: Garbage collection problem
- From: sean_incali at yahoo.com (sean kim)
- Date: Fri, 5 Nov 2004 02:19:18 -0500 (EST)
- References: <cm7d0u$lho$1@smc.vnet.net> <cma0s1$8vg$1@smc.vnet.net> <cmcmbs$ics$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
> Thanks for looking at this.  However, your suggestion actually made
> things worse.  Now, my memory usage increases each time I "run" example
> a, as well as example b.
are you monitoring it as the module is running? like by use of task
manager type of program?
try this... 
In[25]:=
(*Setup*)eq={9.8*(0.99*Cos[qS[t]]+0.01*Cos[qH[t]+qS[t]])-0.01*Sin[qH[t]]*
qH'[
                t]*qS'[t]-0.01*Sin[qH[t]]* qH'[t]*(
        qH'[t]+qS'[t])+(0.001+0.01*Cos[qH[t]])* qH''[t]+(
          0.982+0.02*Cos[qH[t]])*
          qS''[t]\[Equal]0, 0.1*Cos[qH[t]+
            qS[t]]+0.01*Sin[qH[t]]*qS'[t]^2+0.001* 
        qH''[t]+(0.001+0.01*Cos[qH[t]])*qS''[t]\[Equal]0, 
          qS[0]\[Equal]1.71,qS'[0]\[Equal]-1.01,qH[0]\[Equal]2.84,
qH'[0]\
\[Equal]1.1}; vars={qS[t],qH[t],qS'[
    t],qH'[t]}; test=qH[t]≥Pi&& 2*Cos[qH[t]/2]*
        Cos[qH[t]/2+qS[t]]*Sin[Pi/180]+ Cos[Pi/180]*(Cos[
        qS[t]]*Sin[qH[
          t]]+(1+Cos[
            qH[t]])* Sin[qS[t]])<-0.01&&
Cos[qH[t]+qS[t]]*Derivative[1][qH][
            t]+(Cos[qS[t]]+Cos[qH[t]+qS[t]])*
Derivative[1][qS][t]<-0.01||
    Abs[qH[t]]<Pi/6||Sin[qS[t]]<1/4; $HistoryLength=0; (*end*) 
In[26]:=
arun[do_]:= Module[{}, Do[ soln=NDSolve[eq,vars,{t,0,2}][[1]];, {do}]
]
In[36]:=
arun[20] 
MemoryInUse[] 
Share[]
Share[]
arun[200] 
MemoryInUse[] 
Out[37]=
2999248
Out[38]=
264
Out[39]=
0
Out[41]=
2998864
above shows that once you use Module in combination with Share[] (
twice), the memory usage between runnign the module 20x vs 200x is
relatively miniscule.
out38 and 39 show how much Share[] has released. 
similar with the example b. 
In[42]:=
brun[do_]:= Module[{}, Do[ soln=NDSolve[eq,vars,{t,0,
      2},StoppingTest->test][[1]]; , {do}]] 
In[43]:=
brun[20] 
MemoryInUse[] 
Share[]
Share[]
brun[200] 
MemoryInUse[] 
Out[44]=
3057560
Out[45]=
456
Out[46]=
0
Out[48]=
3908176
> Is this problem related to my version/platform of Mathematica?
i'm running windoze xp Mathematica 5.0
> Does anyone know of an equivalent for "ls -l" that I could run on
> Mathematica to track down the memory hog?  I tried several things, but 
> it looks like this memory is out of my reach.
> 
> For example,
> (* begin *)
> objects = Names[];
> sizes = Table[ByteCount[objects[[i]]], {i, Length[objects]}];
> Total[sizes]
> (* end *)
> Running this code snippet doesn't show any increase in the memory used 
> by my objects, even though MemoryInUse[] does.  Therefore, I want to 
> know, where is my memory going?

