#14711: Memleak when creating QuadraticField
-------------------------------------------------+-------------------------
Reporter: jpflori | Owner:
Type: defect | davidloeffler
Priority: critical | Status: new
Component: number fields | Milestone: sage-5.12
Keywords: memleak, number field, | Resolution:
QuadraticField | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: u/SimonKing/ticket/14711 | Commit:
Dependencies: | Stopgaps:
-------------------------------------------------+-------------------------
Comment (by SimonKing):
How about that?
Let D, C be domain and codomain of a coerce map phi. Let us store strong
references from `MonoDict`s `domain._coerce_into_hash` and
`codomain._coerce_from_hash`. Let us create a method of
`phi._make_weak_references()` that turns the default strong references
from phi to its domain and codomain into weak references.
That's to say: We could still use the current backtracking algorithm to
detect coercions (this is since we keep having
`codomain._coerce_from_hash`). We would call `phi._make_weak_references()`
only when registering the coercion. So, I guess the additional overhead
would be small, and the default behaviour of maps would still be safe.
Would this solve our problem? I think so. Assume that there are no
external strong references to C, but there are external strong references
to D. Hence, there is a strong reference from D to phi, but phi (because
we have called `phi._make_weak_references()` only has a ''weak'' reference
to C. Hence, C can be deallocated, and this would trigger the callback for
`D._coerce_into_hash[C]=phi`.
In other words, phi would be removed from the `MonoDict` assigned to `D`.
As a result, C and phi can be collected, but D will survive (because of
the external strong reference).
And you may note that this picture is completely symmetric. Hence, an
external strong reference to C would not be enough to keep phi and D
alive.
Isn't this exactly what we want?
--
Ticket URL: <http://trac.sagemath.org/ticket/14711#comment:37>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.