<div dir="ltr">Through extensive debugging, I've found that the GrADS <i>flush</i> function does not work properly. This first came to my realization when I began to automate my GrADS scripts. Each script processes a single hour by downloading a GRIB file, creating a control file, opening the control file, and displaying/outputting the needed data. The scripts initialize with right around 100 MB of memory but through execution, they can rack up as much as 1.4 GB. Of course when processing multiple hours, this slowed my server to a crawl and in some cases caused crashes (especially with high-res HRRR data for example). Anyway, I traced the excessive memory usage to the display commands. I am aware that with each display command, the displayed variable is stored to the GrADS GRIB2 cache to eliminate further decompression overhead. This is all well given the <i>flush</i> command but it seems to only work half of the time. One can easily see this by noting the initial memory, displaying a few variables, flushing, and then noting the final memory. Seemingly randomly, the memory following a flush will slowly creep up. The behavior memory-wise that I expected from <i>flush</i> can only be obtained with <i>reinit</i> but calling that function thousands of times is not an option. Any ideas as to a work-around or fix? I am using the latest 2.1.a3 version. The first <i>flush</i> below works but the second does not.<div><br><div>-Brandon<br></div><div><br></div><div>---------------------------------------------------------------------------------</div><div>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> !pgrep grads</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">7879</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> ! ps -p 7879 -o %mem,size </font></span></p><p class=""><span style="font-family:monospace,monospace;font-size:x-small">%MEM</span><span style="font-family:monospace,monospace;font-size:x-small"> </span><span style="font-family:monospace,monospace;font-size:x-small">SZ</span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1"> 1.3 87276</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> d tmp2m</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Notice: Automatic Grid Interpolation Taking Place</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Contouring: 255 to 305 interval 5 </font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> ! ps -p 7879 -o %mem,size</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">%MEM SZ</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1"> 1.7 108024</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> d capesfc</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Notice: Automatic Grid Interpolation Taking Place</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Contouring: 0 to 3500 interval 500 </font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> set lat 50 70</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">LAT set to 50 70 </font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> d gustsfc</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Notice: Automatic Grid Interpolation Taking Place</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Contouring: 1 to 13 interval 1 </font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> set lat 20 90</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">LAT set to 20 90 </font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> d tmp2m</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Notice: Automatic Grid Interpolation Taking Place</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Contouring: 255 to 305 interval 5 </font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> flush</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">grib2 cache cleared</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> ! ps -p 7879 -o %mem,size</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">%MEM SZ</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1"> 1.7 108024</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> d tmp2m</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Notice: Automatic Grid Interpolation Taking Place</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">Contouring: 255 to 305 interval 5 </font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> ! ps -p 7879 -o %mem,size</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">%MEM SZ</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1"> 1.9 122908</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> flush</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">grib2 cache cleared</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> ! ps -p 7879 -o %mem,size</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">%MEM SZ</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1"> 1.9 122908</font></span></p>
<p class=""><span class=""><font face="monospace, monospace" size="1">ga-> </font></span></p></div></div></div>