#12313: Fix yet another memory leak caused by caching of coercion data
-------------------------+--------------------------------------------------
   Reporter:  SimonKing  |          Owner:  rlm                     
       Type:  defect     |         Status:  needs_review            
   Priority:  major      |      Milestone:  sage-5.0                
  Component:  memleak    |       Keywords:  coercion weak dictionary
Work_issues:             |       Upstream:  N/A                     
   Reviewer:             |         Author:  Simon King              
     Merged:             |   Dependencies:  #715                    
-------------------------+--------------------------------------------------
Changes (by SimonKing):

  * work_issues:  Find out why some attribute of a parent is deleted before
                  the parent's elements are deleted =>


Comment:

 Replying to [comment:17 vbraun]:
 > You are, in fact, leaking memory: `celement_destruct()` is never called
 if the `AttributeError` is raised.

 Sure. But to my surprise, it isn't noticed in that loop. Surprise,
 because...

 > I guess it only happens rarely in your test loop, so you don't notice it
 in the total memory?

 ... I thought it would be called in each round of the loop.


 > A while ago (when we were both in Kaiserslautern, actually) I fixed
 essentially the same error in `multi_polynomial_libsingular.pyx`: To
 deallocate a singular ring element you need the singular ring, but the
 Python parent can be gone by then. There, I added a new cdef pointer to
 the singular ring to the ring elements.

 So, you agree with the statement from my previous post that keeping a
 reference from the element to the modulus would be the cleanest solution.

 Shall I modify sage/rings/polynomial/polynomial_template.pxi accordingly?

 But there would be a memory penalty (one additional pointer per
 polynomial) and also a time penalty (the pointer needs to be assigned).

 > Usually in OOP you are not allowed to throw exceptions from a
 destructor.

 Sure. The main problem for debugging was that Cython was not able to
 provide the location of the error: Note that it just says "Attribute error
 in  ignored". In fact, it tries to obtain the string representation of the
 polynomial, but it fails for the same reason: The parent's modulus is
 already gone, and without the modulus, the string representation of the
 element can't be determined.

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