#5970: Weak references in Polynomial Ring cache
--------------------------------------------+-------------------------------
   Reporter:  SimonKing                     |          Owner:  malb             
                   
       Type:  defect                        |         Status:  needs_work       
                   
   Priority:  critical                      |      Milestone:  sage-4.8         
                   
  Component:  commutative algebra           |       Keywords:  polynomial ring 
cache weak reference
Work_issues:  regression for test_ec_leak?  |       Upstream:  N/A              
                   
   Reviewer:                                |         Author:                   
                   
     Merged:                                |   Dependencies:                   
                   
--------------------------------------------+-------------------------------

Comment(by SimonKing):

 Aha!

 The combination of a finite field with a polynomial ring seems to reveal
 the leak:
 {{{
 sage: K = GF(next_prime(1000))
 sage: p = K.order()
 sage: predicate = lambda x: is_FiniteField(x) and x.order() == p
 sage: del K
 sage: gc.collect()
 23
 sage: [bla for bla in gc.get_objects() if predicate(bla)]
 []
 sage: K = GF(next_prime(1000))
 sage: P = K['x','y','z']
 sage: del P
 sage: del K
 sage: gc.collect()
 39
 sage: [bla for bla in gc.get_objects() if predicate(bla)]
 [Finite Field of size 1009]
 sage: predicate = lambda x: is_MPolynomialRing(x) and
 x.variable_names()==['x','y','z']
 sage: [bla for bla in gc.get_objects() if predicate(bla)]
 []
 }}}

 So, the polynomial ring is gone, but the base ring remains. And I think
 this is indeed because of the thing tracked at #12215:

  * The polynomial ring belongs to the category of algebras over the base
 ring (at least by #9138, which I have applied),
  * The category is strongly cached (see #12215)
  * The category has a reference to its base ring.

 So, indeed we absolutely need to have `UniqueRepresentation` use weak
 references.

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

Reply via email to