#12313: Fix yet another memory leak caused by caching of coercion data
--------------------------------------------------+-------------------------
       Reporter:  SimonKing                       |         Owner:              
                                         
           Type:  defect                          |        Status:  
positive_review                                      
       Priority:  major                           |     Milestone:  sage-5.3    
                                         
      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:  #11521, #11599, #12969, #12215  |      Stopgaps:              
                                         
--------------------------------------------------+-------------------------

Comment (by nbruin):

 Replying to [comment:249 AlexanderDreyer]:
 >... In the spkg you have a composed C++ class with public attributes,
 that is managed with C++ constructors and destructors. But cython seems
 not to be able to wrap the c++ attributes (unlike `PolyBoRi`'s original
 interface based on boost/python). The only solution I can think of is the
 a flag, which was exactly what this ticket came up with. Alternatively a
 reference count. (I think boost/python uses one or the other internally,
 too.)

 Ah, so the more general solution would be a little class `StratGuard`
 whose instances shepherd the `_strat` objects that
 `GroebnerStrategy._strat.generators` and `ReductionStrategy._strat` refer
 to. Its `__dealloc__` would be the only one that calls the C++ delete.
 Python's own refcounting would do the rest. Whether the actual access to
 the pointer happens through the `StratGuard` object or through a
 separately held pointer (for speed) is a design choice. If this is the
 only use case, though, keeping a flag might be a more light-weight
 solution.

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