#12616: The LP are not deallocated because of cyclic references !
----------------------------------+-----------------------------------------
Reporter: ncohen | Owner: ncohen
Type: defect | Status: needs_work
Priority: major | Milestone: sage-5.0
Component: linear programming | Keywords:
Work_issues: Add doctest | Upstream: N/A
Reviewer: | Author: Nathann Cohen
Merged: | Dependencies:
----------------------------------+-----------------------------------------
Changes (by SimonKing):
* status: needs_review => needs_work
* work_issues: => Add doctest
Comment:
Hi Nathann,
it seems to me that your solution is the cleanest (if a reference is not
needed, then avoid it).
A general remark: Python's garbage collector is able to deal with cyclic
references. There is only one exception I know of: If one or more of the
objects involved in the cycle has a `__del__` method, then Python is not
sure where in the cycle the collection should start.
So, if a reference cycle can not be avoided (e.g., a polynomial ring
R=ZZ['x','y'] points to its generators R.0, R.1, but the generators are
elements and thus point to their parent R), then one could also solve the
problem by not introducing `__del__` methods.
`__dealloc__` (in Cython) is fine, though; but it would only be called
''after'' all Python attributes of the object are gone.
Concerning your patch: Any bug fix ought to be doc tested.
So, could you add a test that demonstrates that the leak is fixed? This
could be along the following lines:
{{{
sage: C = the.class.of.the.object.that.was.leaking
sage: import gc
sage: _ = gc.collect() # avoid side effects of other doc tests
sage: len([x for x in gc.get_objects() if isinstance(x,C)])
0
sage: <some code that would create leaking C instances without your patch>
sage: _ = gc.collect()
sage: len([x for x in gc.get_objects() if isinstance(x,C)])
0
}}}
Of course, it should then also be checked that the last line does not
return 0 without your patch.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12616#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.