<div dir="ltr"><div class="gmail_default" style="font-size:small">Walter,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thanks for sending a little script that shows the issue.  I&#39;m not seeing the same large difference of results as you, but I do see some slight increase.  If I run the script multiple times, I get very different results, so I&#39;m not sure exactly what kind of memory usage is being reported by the &quot;ps&quot; command you provided.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">What version of NCL are you using?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 28, 2015 at 11:22 AM, Walter Hannah <span dir="ltr">&lt;<a href="mailto:walter@hannahlab.org" target="_blank">walter@hannahlab.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I&#39;m having lots of &quot;malloc&quot; errors lately, and I realized that when I use the &quot;delete&quot; function, NCL doesn&#39;t free up as much memory as it created!!!<div><br></div><div>After doing some sleuthing I figured out that the problem happens after I use the reassingment operator &quot;:=&quot; to reduce a variable to a subset of itself like this:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font face="monospace, monospace">X := X(0,:)</font></blockquote></div><div><br></div><div>I&#39;ve come up with a stand alone NCL script (see below) that anyone should be able to run on a linux machine to reproduce the problem. It prints out the memory usage from the &quot;ps&quot; command. </div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="monospace, monospace">procedure printMem (msg)</font></div><div><div><font face="monospace, monospace">local rss,cmd</font></div><div><font face="monospace, monospace">begin</font></div><div><font face="monospace, monospace">    cmd = &quot;ps --no-headers  -o &#39;rss&#39; -C ncl&quot;</font></div><div><font face="monospace, monospace">    rss = max(toint(systemfunc(cmd))) / 1024.</font></div></div><div><font face="monospace, monospace">    print(&quot;NCL memory:    &quot;+sprintf(&quot;%6.2f&quot;,rss)+&quot;     &quot;+msg)</font></div><div><font face="monospace, monospace">end</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">begin</font></div><div><font face="monospace, monospace">    dims = (/10000,100,100/)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">    print(&quot;&quot;)</font></div><div><font face="monospace, monospace">    printMem(&quot;basline memory&quot;)</font></div><div><font face="monospace, monospace">    print(&quot;&quot;)</font></div><div><font face="monospace, monospace">    ;-----------------------------------------------------</font></div><div><font face="monospace, monospace">    ;-----------------------------------------------------</font></div><div><font face="monospace, monospace">    X = new( dims ,float)</font></div><div><font face="monospace, monospace">    printMem(&quot;X created&quot;)</font></div><div><font face="monospace, monospace">    delete(X)</font></div><div><font face="monospace, monospace">    printMem(&quot;X deleted&quot;)</font></div><div><font face="monospace, monospace">    print(&quot;&quot;)</font></div><div><font face="monospace, monospace">    ;-----------------------------------------------------</font></div><div><font face="monospace, monospace">    ;-----------------------------------------------------</font></div><div><font face="monospace, monospace">    X = new( dims ,float)</font></div><div><font face="monospace, monospace">    printMem(&quot;X created&quot;)</font></div><div><font face="monospace, monospace">    X := X</font></div><div><font face="monospace, monospace">    printMem(&quot;X reassigned&quot;)</font></div><div><font face="monospace, monospace">    delete(X)</font></div><div><font face="monospace, monospace">    printMem(&quot;X deleted&quot;)</font></div><div><font face="monospace, monospace">    print(&quot;&quot;)</font></div><div><font face="monospace, monospace">    ;-----------------------------------------------------</font></div><div><font face="monospace, monospace">    ;-----------------------------------------------------</font></div><div><font face="monospace, monospace">end </font></div></blockquote></div><div><br></div><div>The output of the script on my linux machine is:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="monospace, monospace">(0)</font></div><div><font face="monospace, monospace">(0)<span style="white-space:pre-wrap">        </span>NCL memory:     74.38     basline memory</font></div><div><font face="monospace, monospace">(0)</font></div><div><font face="monospace, monospace">(0)<span style="white-space:pre-wrap">        </span>NCL memory:    456.11     X created</font></div><div><font face="monospace, monospace">(0)<span style="white-space:pre-wrap">        </span>NCL memory:     74.66     X deleted</font></div><div><font face="monospace, monospace">(0)</font></div><div><font face="monospace, monospace">(0)<span style="white-space:pre-wrap">        </span>NCL memory:    456.13     X created</font></div><div><font face="monospace, monospace">(0)<span style="white-space:pre-wrap">        </span>NCL memory:    837.44     X reassigned</font></div><div><font face="monospace, monospace">(0)<span style="white-space:pre-wrap">        </span>NCL memory:    456.14     X deleted</font></div><div><font face="monospace, monospace">(0)</font></div></blockquote></div><div><br></div><div>So, after using doing the reassignment it seems that a copy of the variable is left in memory and never cleared.</div><div><br></div><div>I can work around it for now, but I wanted to ask if anyone knew about this, and also can it be fixed?</div><div><br></div><div>Thanks,</div><div>Walter Hannah</div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>