#12215: Memleak in UniqueRepresentation, @cached_method
-----------------------+----------------------------------------------------
   Reporter:  vbraun   |          Owner:  rlm                                   
    
       Type:  defect   |         Status:  new                                   
    
   Priority:  major    |      Milestone:  sage-4.8                              
    
  Component:  memleak  |       Keywords:  UniqueRepresentation cached_method 
caching
Work_issues:           |       Upstream:  N/A                                   
    
   Reviewer:           |         Author:                                        
    
     Merged:           |   Dependencies:                                        
    
-----------------------+----------------------------------------------------
 The documentation says that UniqueRepresentation uses weak refs, but this
 was switched over to the @cached_method decorator. The latter does
 currently use strong references, so unused unique parents stay in memory
 forever:
 {{{
 import sage.structure.unique_representation
 
len(sage.structure.unique_representation.UniqueRepresentation.__classcall__.cache)

 for i in range(2,1000):
     ring = ZZ.quotient(ZZ(i))
     vectorspace = ring^2

 import gc
 gc.collect()
 
len(sage.structure.unique_representation.UniqueRepresentation.__classcall__.cache)
 }}}
 Related tickets:
   * #11521 (needs review, introducing weak references for caching
 homsets), and
   * #715 (needs a lot of work, eventually aiming at using weak references
 for caching coerce maps).

 Further notes:
   * not everything in Python can be weakref'ed, for example ``None``
 cannot.
   * some results that are expensive to compute should not just be cached
 by a weak reference. Perhaps there is place for a permanent cache, or
 maybe some minimal age before garbage collecting it.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12215>
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