[ncl-talk] delete() is not clearing memory?
Walter Hannah
walter at hannahlab.org
Fri Oct 30 05:35:40 MDT 2015
Mary,
I'm currently using version 6.3.0, but I just tested it with 6.2.1 on my
machine, as well as on Yellowstone, and got a similar result.
The numbers were off by a fraction of a MB, but essentially the same.
How different were your numbers?
Walter
On Thu, Oct 29, 2015 at 2:23 PM, Mary Haley <haley at ucar.edu> wrote:
> Walter,
>
> Thanks for sending a little script that shows the issue. I'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'm not sure exactly what kind of memory usage is being
> reported by the "ps" command you provided.
>
> What version of NCL are you using?
>
> --Mary
>
>
> On Wed, Oct 28, 2015 at 11:22 AM, Walter Hannah <walter at hannahlab.org>
> wrote:
>
>> I'm having lots of "malloc" errors lately, and I realized that when I use
>> the "delete" function, NCL doesn't free up as much memory as it created!!!
>>
>> After doing some sleuthing I figured out that the problem happens after I
>> use the reassingment operator ":=" to reduce a variable to a subset of
>> itself like this:
>>
>> X := X(0,:)
>>
>>
>> I'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 "ps" command.
>>
>> procedure printMem (msg)
>> local rss,cmd
>> begin
>> cmd = "ps --no-headers -o 'rss' -C ncl"
>> rss = max(toint(systemfunc(cmd))) / 1024.
>> print("NCL memory: "+sprintf("%6.2f",rss)+" "+msg)
>> end
>>
>> begin
>> dims = (/10000,100,100/)
>>
>> print("")
>> printMem("basline memory")
>> print("")
>> ;-----------------------------------------------------
>> ;-----------------------------------------------------
>> X = new( dims ,float)
>> printMem("X created")
>> delete(X)
>> printMem("X deleted")
>> print("")
>> ;-----------------------------------------------------
>> ;-----------------------------------------------------
>> X = new( dims ,float)
>> printMem("X created")
>> X := X
>> printMem("X reassigned")
>> delete(X)
>> printMem("X deleted")
>> print("")
>> ;-----------------------------------------------------
>> ;-----------------------------------------------------
>> end
>>
>>
>> The output of the script on my linux machine is:
>>
>> (0)
>> (0) NCL memory: 74.38 basline memory
>> (0)
>> (0) NCL memory: 456.11 X created
>> (0) NCL memory: 74.66 X deleted
>> (0)
>> (0) NCL memory: 456.13 X created
>> (0) NCL memory: 837.44 X reassigned
>> (0) NCL memory: 456.14 X deleted
>> (0)
>>
>>
>> So, after using doing the reassignment it seems that a copy of the
>> variable is left in memory and never cleared.
>>
>> I can work around it for now, but I wanted to ask if anyone knew about
>> this, and also can it be fixed?
>>
>> Thanks,
>> Walter Hannah
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151030/1bbfb9cd/attachment.html
More information about the ncl-talk
mailing list