#12313: Fix yet another memory leak caused by caching of coercion data
-------------------------------------------------+--------------------------
       Reporter:  SimonKing                      |         Owner:               
                                        
           Type:  defect                         |        Status:  needs_work   
                                        
       Priority:  major                          |     Milestone:  sage-pending 
                                        
      Component:  memleak                        |    Resolution:               
                                        
       Keywords:  coercion weak dictionary       |   Work issues:               
                                        
Report Upstream:  N/A                            |     Reviewers:  Simon King, 
Jean-Pierre Flori, John Perry, Nils Bruin
        Authors:  Simon King, Jean-Pierre Flori  |     Merged in:               
                                        
   Dependencies:  #715, #11521, #12215, #13746   |      Stopgaps:               
                                        
-------------------------------------------------+--------------------------

Comment (by nbruin):

 Replying to [comment:268 SimonKing]:
 > * Can we be sure that `self.D` is not None when the `TripleDictEraser`
 is called?
 I think so. Setting `self.D=None` must be part of a dealloc on the
 `TripleDictEraser` itself. I don't see how Python could consider it not a
 bug to call a `__call__` method that is in the process of being dealloc-ed
 (see my [comment:267 remark])

 > ... and gc decided to delete it first. Hence, when calling the eraser,
 the `TripleDict` itself and not just its buckets is already gone.

 That's why the Python GC does take some efforts to avoid calling avoidable
 weakref callbacks.

 > * Shouldn't the same be done with the `MonoDictEraser`?

 I figured this was probably triggered by an interaction of a non-
 weakreffable key component holding a reference to a weakreffable key
 component, which doesn't happen in `MonoDict`. On the other hand, objects
 in `MonoDict` could have a `TripleDict` on an attribute somewhere and I
 don't immediately see a proof that such a construct could still lead to
 this kind of nasty cycle (especially because I don't quite understand the
 nature of the loop here that makes python execute this unnecessary
 callback. Apparently Python doesn't purge ''all'' garbage callbacks before
 doing ''any'' deletions on cyclic trash)

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