Discussion:
[sage-devel] Other memory leaks
Jori Mäntysalo
2018-12-01 16:04:58 UTC
Permalink
For example PS_all_new_cells in
src/sage/groups/perm_gps/partn_ref/data_structures.pyx contains
bitset_init(scratch, n) but there is no bitset_free(scratch) anywhere.
Does that mean that the function leaks memory?

Then, in src/sage/graphs/independent_sets.pyx the class IndependentSets
seems to have a __dealloc__() thas does NOT contain
bitset_free(current_set) and so I guess we have exactly same problem that
in breadth_first_search() we are just correcting.

As a counter-example, in src/sage/graphs/weakly_chordal.pyx there is
function is_long_hole_free() containing

bitset_init(dense_graph, n * n)
if ...:
bitset_free(dense_graph)
return ...
bitset_free(dense_graph)
return ...

so that seems to be correct.

I found these by

egrep -R -o 'bitset_init\([[:alnum:].]+,|bitset_free\([[:alnum:].]+' src/sage | less

but I suppose that there are better tools for this.
--
Jori Mäntysalo
'Martin R' via sage-devel
2018-12-01 16:14:16 UTC
Permalink
I confirm that the following leaks:

def bad8(n):
"""
sage: bad8(100000)
"""
from sage.graphs.independent_sets import IndependentSets
G = Graph(2)
for i in range(n):
x = [0] in IndependentSets(G)
if i % 10000 == 0:
print get_memory_usage()
--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+***@googlegroups.com.
To post to this group, send email to sage-***@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.
Jori Mäntysalo
2018-12-01 16:22:44 UTC
Permalink
I created https://trac.sagemath.org/ticket/26795 for this and similar.
--
Jori MÀntysalo
Loading...