#4883: possible memory leak in sage.matrix.matrix_integer_dense
---------------------+------------------------------------------------------
 Reporter:  burcin   |       Owner:  mabshoff
     Type:  defect   |      Status:  new     
 Priority:  major    |   Milestone:  sage-3.3
Component:  memleak  |    Keywords:          
---------------------+------------------------------------------------------
 {{{
     def __dealloc__(self):
         """
         Frees all the memory allocated for this matrix.
         EXAMPLE:
             sage: a = Matrix(ZZ,2,[1,2,3,4])
             sage: del a
         """
         cdef Py_ssize_t i
         if self._initialized:
             for i from 0 <= i < (self._nrows * self._ncols):
                 mpz_clear(self._entries[i])
             sage_free(self._entries)
             sage_free(self._matrix)
 }}}

 It is possible that `_initialized` is not set but `_matrix` and `_entries`
 are allocated.

 Error paths in `__new__` and `__init__` should also be revised, since if
 one raises an error in these functions python still calls `__dealloc__`
 for the cleanup.

 From the `__init__` function:
 {{{
         elif isinstance(entries, (int,long)) or is_Element(entries):
             try:
                 x = ZZ(entries)
             except TypeError:
                 self._initialized = False
                 raise TypeError, "unable to coerce entry to an integer"
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4883>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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