On Wed, 28 Nov 2018, 'Martin R' via sage-devel wrote:
Can you confirm that running check_bad3 above allocates memory without
limits?
Confirmed.
I got it: breadth_first_search (used in HasseDiagram.is_lequal) leaks.
if I use breadth_first_search(i, distance=self.cardinality()) instead, the leak
is gone.
That function starts with
# Preferably use the Cython implementation
if neighbors is None and . . . distance is None and . . .
so the problem must be in
for v in self._backend.breadth_first_search(start,
ignore_direction=ignore_direction):
yield v
This goes to src/sage/graphs/base/c_graph.pyx cdef class Search_iterator,
which has
def __next__(self):
. . .
cdef bitset_t seen
. . .
def __init__
. . .
bitset_init(self.seen,
. . .
def __next__(self):
. . .
while self.stack:
. . .
break
else:
bitset_free(self.seen)
raise StopIteration
So, now when there is no reference to Search_iterator any more, should
Cython automatically clean up the space taken, or should there be an
explicit destructor?
--
Jori Mäntysalo