#12357: Make groupoids garbage collectable
------------------------------------------------+---------------------------
       Reporter:  SimonKing                     |         Owner:  rlm           
                
           Type:  defect                        |        Status:  closed        
                
       Priority:  major                         |     Milestone:  
sage-duplicate/invalid/wontfix
      Component:  memleak                       |    Resolution:  duplicate     
                
       Keywords:  groupoid cache Cernay2012     |   Work issues:                
                
Report Upstream:  N/A                           |     Reviewers:  Simon King, 
Jean-Pierre Flori 
        Authors:                                |     Merged in:                
                
   Dependencies:  #715, #11521, #12313, #11943  |      Stopgaps:                
                
------------------------------------------------+---------------------------
Changes (by jdemeyer):

  * status:  positive_review => closed
  * reviewer:  Jean-Pierre Flori => Simon King, Jean-Pierre Flori
  * resolution:  => duplicate
  * author:  Simon King =>


Old description:

> Currently, the groupoid of an object P can not be garbage collected, even
> when deleting P.
>
> Even worse: The persistence of `Groupoid(P)` also prevents P from being
> garbage collected.
>
> The attached patch aims at solving it: An external reference to either P
> or `Groupoid(P)` is enough to keep both alive. But without an external
> reference, both P and `Groupoid(P)` become collectable.
>
> Example from the docs:
> {{{
>             sage: P = GF(151)['x','y']
>             sage: n = id(Groupoid(P))
>             sage: import gc
>             sage: _ = gc.collect()
>             sage: n == id(Groupoid(P))   # indirect doctest
>             True
>
>         Thus, the groupoid is cached. But when deleting ``P``, its
>         groupoid can be garbage collected as well::
>
>             sage: del P
>             sage: _ = gc.collect()
>             sage: P = GF(151)['x','y']
>             sage: n == id(Groupoid(P))
>             False
>
>         TESTS:
>
>         We test against some corner cases::
>
>             sage: Groupoid(None)
>             Traceback (most recent call last):
>             ...
>             TypeError: Groupoid of None is not defined
>             sage: Groupoid(1)
>             Traceback (most recent call last):
>             ...
>             TypeError: 1 must either allow attribute assignment or be
> instances of <type 'sage.structure.parent.Parent'>
>             sage: class A: pass
>             sage: a = A()
>             sage: Groupoid(a)
>             Groupoid with underlying set <__main__.A instance at ...>
>             sage: Groupoid(a) is Groupoid(a)
>             True
> }}}
>
> Apply:
>
>  - [attachment:trac12357_internal_strong_groupoid_cache.patch]
>  - [attachment:trac12357_reviewer.patch]

New description:

 Currently, the groupoid of an object P can not be garbage collected, even
 when deleting P.

 Even worse: The persistence of `Groupoid(P)` also prevents P from being
 garbage collected.

 The attached patch aims at solving it: An external reference to either P
 or `Groupoid(P)` is enough to keep both alive. But without an external
 reference, both P and `Groupoid(P)` become collectable.

 Example from the docs:
 {{{
             sage: P = GF(151)['x','y']
             sage: n = id(Groupoid(P))
             sage: import gc
             sage: _ = gc.collect()
             sage: n == id(Groupoid(P))   # indirect doctest
             True

         Thus, the groupoid is cached. But when deleting ``P``, its
         groupoid can be garbage collected as well::

             sage: del P
             sage: _ = gc.collect()
             sage: P = GF(151)['x','y']
             sage: n == id(Groupoid(P))
             False

         TESTS:

         We test against some corner cases::

             sage: Groupoid(None)
             Traceback (most recent call last):
             ...
             TypeError: Groupoid of None is not defined
             sage: Groupoid(1)
             Traceback (most recent call last):
             ...
             TypeError: 1 must either allow attribute assignment or be
 instances of <type 'sage.structure.parent.Parent'>
             sage: class A: pass
             sage: a = A()
             sage: Groupoid(a)
             Groupoid with underlying set <__main__.A instance at ...>
             sage: Groupoid(a) is Groupoid(a)
             True
 }}}

 Superseded by #12313.

--

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


Reply via email to