#14356: memleak in UniqueRepresentation / Poset
---------------------------+--------------------------
       Reporter:  vbraun   |        Owner:  rlm
           Type:  defect   |       Status:  needs_info
       Priority:  major    |    Milestone:  sage-5.12
      Component:  memleak  |   Resolution:
       Keywords:           |    Merged in:
        Authors:           |    Reviewers:
Report Upstream:  N/A      |  Work issues:
         Branch:           |       Commit:
   Dependencies:           |     Stopgaps:
---------------------------+--------------------------

Comment (by nbruin):

 I think I agree with Simon's assessment that the code behaves as designed
 and hence that strictly speaking, the memory leak is created by misuse.
 However, I think we have a problematic design if it's that easy to
 "misuse" it so easily.

 I think this issue indicates that perhaps parents like Poset should NOT be
 unique. If we go back to why "unique" parent were introduced we see:
  - it means that polynomials in QQ!['x'] created in two separate places
 will actually lie in the same parent
  - it makes some things easier/faster in the coercion framework

 Keeping strong references globally to the construction parameters of a
 parent for the lifetime of the parent is OK if the parameters are
 fundamentally "simpler" than the constructed object. However, that's not
 the case with constructing a Poset: the entire complexity of the object is
 part of the construction call.

 That makes it rather unlikely that the uniquerepresentation feature will
 ever make a useful contribution. It also means that constructing an
 n-element Poset is at least O(n), because !UniqueRepresentation will walk
 the call argument (i.e., all the labels!) to hash them, converting lists
 to something hashable. Note that constructing a Poset from a set should
 normally be O(1), because the only thing required is saving a reference to
 the set and the comparison method.

 So, I think parents that require more than O(1) [in some reasonable sense]
 construction parameter complexity should probably usually not be
 !UniqueRepresentation.

 Poset seems to have explicitly designed to be !UniqueRepresentation, so I
 assume someone really needed that. It does mean, though, that if someone
 needs a Poset but doesn't particularly need it to be
 !UniqueRepresentation, they should probably not use Poset, because it's an
 expensive feature for parents like this.

--
Ticket URL: <http://trac.sagemath.org/ticket/14356#comment:6>
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.

Reply via email to