<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
</head><body><p>Hi all,<br></p><p><br></p><p>I am trying to read a large number of files, using the data to fill an array which has been declared with a new statement. After each file is read, all arrays no longer needed are deleted prior to reading the next file. Yet after 80 files are read, I get an NhlMalloc Failed error. "fatal:NhlMalloc Failed:[errno=12]". If I read all the files in smaller groups with individual runs of the program, I get no errors, which suggests the files them selves are not to blame. It SEEMS there is a memory leak. I have tried many things and read this forum on the topic. </p><p><br></p><p>My ncl version for RedHat is ncl_ncarg-6.3.0.Linux_RHEL5.11_i686_nodap_gcc412.tar.gz.<br></p><p><br></p><p>Code snippet of loop within which error occurs:<br></p><p>___________________________________________________________</p><p> naz = 720<br> nr = 976</p><p class="default-style">infile = systemfunc("ls rawdats/rawdat0*")</p><p class="default-style">nfiles = dimsizes(infile)</p><p class="default-style">gate = 50.0 ; from swp metadata</p><p class="default-style">stats = new((/nfiles,naz,nr/),"float")<br> stats@_FillValue = bad<br> stats = stats@_FillValue<br> maxfield = new((/naz,nr/),"float")<br> maxfield@_FillValue = bad<br> maxfield = 0.0<br> maxlat = new((/naz,nr/),"float")<br> maxlon = new((/naz,nr/),"float")</p><p class="default-style">do ifile = 0,nfiles-1<br> indat = readAsciiTable(infile(ifile),7,"float",1)<br> field = indat(:,5)<br> lat1d = indat(:,0)<br> lon1d = indat(:,1)</p><p class="default-style"> numrows = dimsizes(field)<br> az = indat(:,2)<br> rn = indat(:,3)</p><p class="default-style"> do i = 0,numrows-1<br> ; Determine indeces for az,range and load into stats array<br> iaz = toint(floor(az(i)/0.5))<br> ir = toint(floor(rn(i)/gate))</p><p class="default-style"> ; Add this data to stats array<br> stats(ifile,iaz,ir) = abs(field(i))</p><p class="default-style"> maxlat(iaz,ir) = lat1d(i)<br> maxlon(iaz,ir) = lon1d(i)</p><p class="default-style"> end do</p><p class="default-style"> delete(indat)<br> delete(numrows)<br> delete(az)<br> delete(rn)<br> delete(field)<br> delete(lat1d)<br> delete(lon1d)<br> end do<br></p><p class="default-style">_______________________________________________________________<br></p><p class="default-style">Any ideas?<br></p><p class="default-style"><br></p><p class="default-style">Paul Robinson<br></p><p class="default-style">Center for Severe Weather Research in Boulder, CO<br></p></body></html>