#11521: Memleak when resolving the action of Integers on an Elliptic Curve
------------------------+---------------------------------------------------
Reporter: jpflori | Owner: robertwb
Type: defect | Status: needs_work
Priority: major | Milestone: sage-4.8
Component: coercion | Keywords: sd35
Work_issues: | Upstream: N/A
Reviewer: | Author: Simon King
Merged: | Dependencies: #11900 #715
------------------------+---------------------------------------------------
Comment(by SimonKing):
Replying to [comment:94 jpflori]:
> Indeed, has all the dicts for coercion caches have weakrefs to their
values, the actions get garbage collected. That becomes kind of tricky...
Yes, and note that we have two locations for storing the actions:
* in the coercion model
* in the attribute `_action_hash` of parents.
I found that having weak references in the coercion model is enough for
fixing the leak - even if one has strong references in `_action_hash`.
That is something I don't fully understand. In the example of the ticket
description, we have an action of `ZZ`. `ZZ` is not subject to garbage
collection, hence, having a strong reference in `ZZ._action_hash` should
keep the action alive, and thus the elliptic curve (namely the different
copies of E that are created in the loop).
Anyway, even in that case we would see the drastic slow-down.
> As pointed before, the problem is that if we let strong reference to the
actions in the values of the dict, these action themselves have strong
refs to the domain and codomain and so prevent the whole garbage
collection to occur. Is it sensible to use weakrefs for [co]domains in
Functors? Hence garbage collection can occur in the cache dicts, but if
someone actually use functors directly, he must be sure to have some
strong references to its domain and codomain somewhere to avoid garbage
collection...
Indeed that would be the consequence. I think that would not be
acceptable: If the user keeps an action, then s/he can rightfully expect
that domain and codomain are automatically kept alive.
> Another question: why not use a TripleDict in the parent class for the
_action_hash dict rather that a WeakValueDict with three keys? That could
somehow unify the approach taken here!
I was thinking of that, too. However, in addition to `_action_hash`, the
parent also has a `_action_list`. And that might be a bigger problem.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11521#comment:95>
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.