#14356: memleak in UniqueRepresentation / Poset
---------------------------+------------------------------------------------
Reporter: vbraun | Owner: rlm
Type: defect | Status: needs_info
Priority: major | Milestone: sage-5.9
Component: memleak | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
---------------------------+------------------------------------------------
Comment (by SimonKing):
Replying to [comment:1 vbraun]:
> It seems that this is a rather common use of posets: You have some
objects that refer back to their common container.
It is indeed normal that, e.g., an element refers to its parent. Hence,
the element keeps the parent alive. But:
> Now label the poset elements with. This then keeps everything alive.
If the element is gone, the parent can be garbage collected. Or "should
be" garbage collected.
Hence, what is the difference to the element vs. parent situation?
Here, we have foo, which points to a poset (let's call it P) as an
attribute foo.poset. Part of the construction of P are the element_labels,
which refer to foo. Since the construction data of P are stored as keys of
a weak value dictionary, they are kept alive.
Hence, foo is alive, and thus P=foo.poset, too.
I'd say this is impossible to prevent automatically (see below).
> Questions:
> * Maybe Poset should support for weakly referenced labels?
That should solve this problem.
> * !UniqueRepresentations could check that the key does not have a
reference to the value for debugging purposes
How could this be checked?
Note that the reference does not exist when
`UniqueRepresentation.__classcall__` is called! Namely, first the poset is
constructed, and only in the second step the poset is assigned to
foo.poset. But during construction, there is no reason for Sage to guess
that the user will ''later'' create a strong reference from the key to the
resulting poset.
So, I'd say it is a misuse.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14356#comment:2>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.