#12313: Fix yet another memory leak caused by caching of coercion data
-----------------------------------------------------------------------------------------------------------+
Reporter: SimonKing
| Owner: rlm
Type: defect
| Status: needs_review
Priority: major
| Milestone: sage-5.0
Component: memleak
| Keywords: coercion weak dictionary
Work_issues: Find out why some attribute of a parent is deleted before the
parent's elements are deleted | Upstream: N/A
Reviewer:
| Author: Simon King
Merged:
| Dependencies: #715
-----------------------------------------------------------------------------------------------------------+
Comment(by vbraun):
You are correct, in `__dealloc__` it is not safe to look at any Python
attribute. Usually they are still around, especially if they are being
kept alive by some other reference. But not always, and there is no way to
tell if they are.
You are, in fact, leaking memory: `celement_destruct()` is never called if
the `AttributeError` is raised. I guess it only happens rarely in your
test loop, so you don't notice it in the total memory? A while ago (when
we were both in Kaiserslautern, actually) I fixed essentially the same
error in `multi_polynomial_libsingular.pyx`: To deallocate a singular ring
element you need the singular ring, but the Python parent can be gone by
then. There, I added a new cdef pointer to the singular ring to the ring
elements.
Usually in OOP you are not allowed to throw exceptions from a destructor.
Same with C++, for example.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12313#comment:17>
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.