Memory leak with if statement and logical array

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Thu, 19 Apr 2007 18:43:29 -0600

Hello. I would like to report a possible memory leak problem in NCL
version 4.2.0.a034. This occurs when using an array of type logical
within an if statement. A significant amount of memory is lost each
time this statement is executed:

    if (flags(x)) then

If the direct array reference is changed to a logical expression,
the problem goes away:

    if (flags(x) .eq. True) then

The second form is a good workaround, but it might save significant
debugging time if the first form could be fixed.

Please see the attached script for a working demo. The double
nested loop is necessary in the complex application that I was
developing. Otherwise I would have never noticed the leak.

I am running NCL version 4.2.0.a034 on Mac OS:

mac56:~/narr 173> uname -a
Darwin mac56.cdc.noaa.gov 8.9.0 Darwin Kernel Version 8.9.0: Thu Feb
22 20:54:07 PST 2007; root:xnu-792.17.14~1/RELEASE_PPC Power
Macintosh powerpc

Thanks in advance to the NCL team for any bug fix that might be
provided.

--Dave A.
CU/CIRES Climate Diagnostics Center (CDC)
NOAA/ESRL/PSD, Climate Analysis Branch (CAB)

; Demo of NCL memory leak with if statement and logical array.
; Problem occurs with NCL version 4.2.0.a034 on Mac OS,
; Darwin Kernel Version 8.9.0
; 2007-apr-19

begin
   flags = new ((/ 10000 /), logical)
   flags = True
   count = 0d

   do j = 1, 100
      print ("Main loop "+j)
      
      do x = 0, 9999 ; memory is lost every time
         if (flags(x)) then ; around this loop
            count = count + 1
         end if
      end do
   end do
end

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Apr 19 2007 - 18:43:29 MDT

This archive was generated by hypermail 2.2.0 : Thu Apr 26 2007 - 08:55:37 MDT