<html><body>
<p>1 new commit in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/9c03543ba85f/">https://bitbucket.org/yt_analysis/yt/commits/9c03543ba85f/</a> Changeset:   9c03543ba85f Branch:      yt User:        ngoldbaum Date:        2016-03-24 18:29:09+00:00 Summary:     Merged in xarthisius/yt (pull request #2036)</p>
<p>Fix memory leak in ARTIO Affected #:  2 files</p>
<p>diff -r 10bf552980ab547ece30ab77e8ccd522d440a74e -r 9c03543ba85f4f0aa07f2f0261724831cedfe754 yt/frontends/artio/_artio_caller.pyx --- a/yt/frontends/artio/_artio_caller.pyx +++ b/yt/frontends/artio/_artio_caller.pyx @@ -718,12 +718,13 @@</p>
<pre>cdef np.int64_t **pcount
cdef float **root_mesh_data
cdef np.int64_t nvars[2]</pre>
<p>+    cdef int cache_root_mesh</p>
<pre>     def __init__(self, domain_dimensions, # cells
domain_left_edge,
domain_right_edge,
artio_fileset artio_handle,</pre>
<ul><li><p>sfc_start, sfc_end):</p></li></ul>
<p>+                 sfc_start, sfc_end, int cache_root_mesh = 0):</p>
<pre>cdef int i
cdef np.int64_t sfc
self.sfc_start = sfc_start</pre>
<p>@@ -735,6 +736,7 @@</p>
<pre>self.oct_count = None
self.root_mesh_data = NULL
self.pcount = NULL</pre>
<p>+        self.cache_root_mesh = cache_root_mesh</p>
<pre>         if artio_handle.has_particles:
self.pcount = <np.int64_t **> malloc(sizeof(np.int64_t*)</pre>
<p>@@ -789,10 +791,11 @@</p>
<pre>         cdef float *grid_variables = <float *>malloc(
ngv * sizeof(float))
         self.octree_handler = octree = ARTIOOctreeContainer(self)</pre>
<ul><li><p>self.root_mesh_data = <float **>malloc(sizeof(float *) * ngv)</p></li>
<li><p>for i in range(ngv):</p></li>
<li><p>self.root_mesh_data[i] = <float *>malloc(sizeof(float) * \</p></li>
<li><p>(self.sfc_end – self.sfc_start + 1))</p></li></ul>
<p>+        if self.cache_root_mesh == 1: +            self.root_mesh_data = <float **>malloc(sizeof(float *) * ngv) +            for i in range(ngv): +                self.root_mesh_data[i] = <float *>malloc(sizeof(float) * \ +                    (self.sfc_end – self.sfc_start + 1))</p>
<pre># We want to pre-allocate an array of root pointers.  In the future,
# this will be pre-determined by the ARTIO library.  However, because
# realloc plays havoc with our tree searching, we can't utilize an</pre>
<p>@@ -808,7 +811,7 @@</p>
<pre>    sfc, dpos, grid_variables, &num_oct_levels,
    num_octs_per_level)
check_artio_status(status)</pre>
<ul><li><p>for i in range(ngv):</p></li></ul>
<p>+            for i in range(ngv * self.cache_root_mesh):</p>
<pre>    self.root_mesh_data[i][sfc - self.sfc_start] = \
        grid_variables[i]
if num_oct_levels > 0:</pre>
<p>@@ -823,7 +826,6 @@</p>
<pre>check_artio_status(status)
         status = artio_grid_clear_sfc_cache(self.handle)
         check_artio_status(status)</pre>
<p>–</p>
<pre>         if self.artio_handle.has_particles:
num_particles_per_species =  <int *>malloc(
        sizeof(int)*num_species)</pre>
<p>@@ -1505,10 +1507,15 @@</p>
<pre>cdef np.int64_t sfc, num_cells, sfci = -1
cdef np.float64_t val
cdef double dpos[3]</pre>
<p>+        max_level = self.artio_handle.max_level +        cdef int *num_octs_per_level = <int *>malloc( +            (max_level + 1)*sizeof(int))</p>
<pre># We duplicate some of the grid_variables stuff here so that we can
# potentially release the GIL
nf = len(field_indices)
ngv = self.artio_handle.num_grid_variables</pre>
<p>+        cdef float *grid_variables = <float *>malloc( +            ngv * sizeof(float))</p>
<pre>cdef np.ndarray[np.uint8_t, ndim=1, cast=True] mask
mask = self.mask(selector, -1)
num_cells = self._last_mask_sum</pre>
<p>@@ -1528,17 +1535,39 @@</p>
<pre># location based on the file index.
cdef int filled = 0
cdef float **mesh_data = self.range_handler.root_mesh_data</pre>
<ul><li><p>for sfc in range(self.sfc_start, self.sfc_end + 1):</p></li>
<li><p>if self.sfc_mask[sfc – self.sfc_start] == 0: continue</p></li>
<li><p>sfci += 1</p></li>
<li><p>if mask[sfci] == 0: continue</p></li>
<li><p>for i in range(nf):</p></li>
<li><p>field_vals[i][filled] = mesh_data[field_ind[i]][</p></li>
<li><p>sfc – self.sfc_start]</p></li>
<li><p>filled += 1</p></li></ul>
<p>+        if mesh_data == NULL: +            status = artio_grid_cache_sfc_range(self.handle, self.sfc_start, +                                                self.sfc_end) +            check_artio_status(status) +            for sfc in range(self.sfc_start, self.sfc_end + 1): +                if self.sfc_mask[sfc – self.sfc_start] == 0: continue +                sfci += 1 +                if mask[sfci] == 0: continue +                status = artio_grid_read_root_cell_begin( self.handle, +                    sfc, dpos, grid_variables, &num_oct_levels, +                    num_octs_per_level) +                check_artio_status(status) +                for i in range(nf): +                    field_vals[i][filled] = grid_variables[field_ind[i]] +                filled += 1 +                status = artio_grid_read_root_cell_end(self.handle) +                check_artio_status(status) +            status = artio_grid_clear_sfc_cache(self.handle) +            check_artio_status(status) +        else: +            for sfc in range(self.sfc_start, self.sfc_end + 1): +                if self.sfc_mask[sfc – self.sfc_start] == 0: continue +                sfci += 1 +                if mask[sfci] == 0: continue +                for i in range(nf): +                    field_vals[i][filled] = mesh_data[field_ind[i]][ +                        sfc – self.sfc_start] +                filled += 1</p>
<pre># Now we have all our sources.
free(field_ind)
free(field_vals)</pre>
<p>+        free(grid_variables) +        free(num_octs_per_level)</p>
<pre>        return tr

    @cython.boundscheck(False)</pre>
<p>diff -r 10bf552980ab547ece30ab77e8ccd522d440a74e -r 9c03543ba85f4f0aa07f2f0261724831cedfe754 yt/frontends/artio/data_structures.py --- a/yt/frontends/artio/data_structures.py +++ b/yt/frontends/artio/data_structures.py @@ -164,6 +164,7 @@</p>
<pre>        self.directory = os.path.dirname(self.index_filename)

        self.max_level = ds.max_level</pre>
<p>+        self.range_handlers = {}</p>
<pre>        self.float_type = np.float64
        super(ARTIOIndex, self).__init__(ds, dataset_type)
</pre>
<p>@@ -251,11 +252,15 @@</p>
<pre>#v = np.array(list_sfc_ranges)
#list_sfc_ranges = [ (v.min(), v.max()) ]
for (start, end) in list_sfc_ranges:</pre>
<ul><li><p>range_handler = ARTIOSFCRangeHandler(</p></li>
<li><p>self.ds.domain_dimensions,</p></li>
<li><p>self.ds.domain_left_edge, self.ds.domain_right_edge,</p></li>
<li><p>self.ds._handle, start, end)</p></li>
<li><p>range_handler.construct_mesh()</p></li></ul>
<p>+                if (start, end) in self.range_handlers.keys(): +                    range_handler = self.range_handlers[(start, end)] +                else: +                    range_handler = ARTIOSFCRangeHandler( +                        self.ds.domain_dimensions, +                        self.ds.domain_left_edge, self.ds.domain_right_edge, +                        self.ds._handle, start, end) +                    range_handler.construct_mesh() +                    self.range_handlers[(start, end)] = range_handler</p>
<pre>if nz != 2:
    ci.append(ARTIORootMeshSubset(base_region, start, end,
                range_handler.root_mesh_handler, self.ds))</pre>
<p>Repository URL: <a href="https://bitbucket.org/yt_analysis/yt/">https://bitbucket.org/yt_analysis/yt/</a></p>
<p>—</p>
<p>This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.</p>

<img src="http://link.bitbucket.org/wf/open?upn=ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27AtFa2nk9wyrEXZN74uSji60WNGerRg2UiCQKJtUaA8ZwfGeh6wLeiV1R8KmXEaiTZFXC7u8h-2BD-2BW27OzPTENw3pyKzut-2BRqp7MOSIs81PVTmnm55uroz7sMCeJvSOz7klUv2DzzMr9-2Fj4UI-2F8iyBtCLhvymNM3rKD-2FC7QzF1351AZmOk4k3Lnrx1v-2Bbi5pnBQ-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>