#18897: Memory leak in polynomial_compiled.univar_pd
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:
  slabbe                 |       Status:  needs_review
           Type:         |    Milestone:  sage-6.8
  defect                 |   Resolution:
       Priority:         |    Merged in:
  critical               |    Reviewers:
      Component:         |  Work issues:
  memleak                |       Commit:
       Keywords:         |  80ce8765811c7ac18b921467e113630169b6aaaf
        Authors:  Simon  |     Stopgaps:
  King                   |
Report Upstream:  N/A    |
         Branch:         |
  public/18897           |
   Dependencies:         |
-------------------------+-------------------------------------------------

Comment (by SimonKing):

 {{{
 sage: L = [1,1,0,1,0,1,2,1,1,0,0,1,2,0,0,1,1,0,2,0,0,0,0,0,1]
 sage: def test(L, dim):
 ....:     import gc
 ....:     from collections import Counter
 ....:     gc.collect()
 ....:     pre={id(c) for c in gc.get_objects()}
 ....:     m = matrix(dim, L)
 ....:     for p in range(2,102):
 ....:         m.change_ring(GF(nth_prime(p))).eigenvalues()
 ....:     gc.collect()
 ....:     post=Counter(type(o) for o in gc.get_objects() if id(o) not in
 pre)
 ....:     return [(k,v) for (k,v) in post.iteritems() if v>10]
 ....:
 sage: test(L, 5)
 [(<class
 
'sage.rings.algebraic_closure_finite_field.AlgebraicClosureFiniteField_pseudo_conway_with_category'>,
   100),
  (<type 'sage.libs.ntl.ntl_ZZ_pX.ntl_ZZ_pX'>, 76),
  (<type
 'sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint'>,
   2494),
  (<class
 'sage.rings.finite_rings.homset.FiniteFieldHomset_with_category'>,
   76),
  (<type 'sage.categories.morphism.IdentityMorphism'>, 153),
  (<class 'sage.rings.homset.RingHomset_quo_ring_with_category'>, 100),
  (<type 'weakref'>, 3700),
  (<type 'sage.categories.map.FormalCompositeMap'>, 200),
  (<class
 
'sage.rings.finite_rings.finite_field_givaro.FiniteField_givaro_with_category'>,
   16),
  (<class
 'sage.modules.free_module.FreeModule_ambient_field_with_category'>,
   60),
  (<type 'sage.libs.ntl.ntl_ZZ_pEContext.ntl_ZZ_pEContext_class'>, 75),
  (<type 'sage.categories.morphism.CallMorphism'>, 197),
  (<class
 
'sage.rings.polynomial.polynomial_ring.PolynomialRing_dense_mod_p_with_category'>,
   176),
  (<type 'list'>, 8080),
  (<type
 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement'>,
   523),
  (<type 'sage.rings.finite_rings.integer_mod.NativeIntStruct'>, 100),
  (<type 'sage.rings.finite_rings.integer_mod.Int_to_IntegerMod'>, 200),
  (<type 'sage.misc.cachefunc.CachedMethodCallerNoArgs'>, 382),
  (<type 'sage.misc.constant_function.ConstantFunction'>, 3050),
  (<class 'sage.rings.ideal.Ideal_pid'>, 100),
  (<type
 
'sage.rings.finite_rings.hom_prime_finite_field.FiniteFieldHomomorphism_prime'>,
   76),
  (<class
 
'sage.rings.finite_rings.finite_field_prime_modn.FiniteField_prime_modn_with_category'>,
   100),
  (<class 'sage.structure.sequence.Sequence_generic'>, 75),
  (<type 'dict'>, 2034),
  (<type 'sage.misc.cachefunc.CachedMethodCaller'>, 123),
  (<class
 'sage.rings.finite_rings.conway_polynomials.PseudoConwayLattice'>,
   100),
  (<type 'staticmethod'>, 132),
  (<type 'cell'>, 204),
  (<type 'sage.structure.element.NamedBinopMethod'>, 13),
  (<type 'sage.rings.finite_rings.integer_mod.Integer_to_IntegerMod'>,
 176),
  (<type 'sage.rings.finite_rings.element_givaro.Cache_givaro'>, 16),
  (<type
 'sage.rings.polynomial.polynomial_element.PolynomialBaseringInjection'>,
   200),
  (<type 'classobj'>, 13),
  (<type 'function'>, 1817),
  (<type 'property'>, 37),
  (<class
 
'sage.rings.finite_rings.finite_field_pari_ffelt.FiniteField_pari_ffelt_with_category'>,
   60),
  (<class 'sage.rings.homset.RingHomset_generic_with_category'>, 100),
  (<class 'sage.structure.dynamic_class.DynamicMetaclass'>, 72),
  (<type 'frozenset'>, 33),
  (<type 'sage.structure.coerce_dict.MonoDictEraser'>, 2087),
  (<type 'sage.structure.coerce_dict.TripleDict'>, 1043),
  (<type 'instancemethod'>, 609),
  (<type
 'sage.rings.finite_rings.element_pari_ffelt.FiniteFieldElement_pari_ffelt'>,
   180),
  (<class 'sage.structure.dynamic_class.DynamicClasscallMetaclass'>, 21),
  (<type 'wrapper_descriptor'>, 513),
  (<type 'instance'>, 106),
  (<type 'sage.libs.ntl.ntl_ZZ_pContext.ntl_ZZ_pContext_class'>, 76),
  (<type 'getset_descriptor'>, 202),
  (<class
 'sage.rings.finite_rings.homset.FiniteFieldHomset_with_category'>,
   76),
  (<type 'sage.structure.coerce_dict.MonoDict'>, 2087),
  (<type 'sage.structure.coerce_maps.DefaultConvertMap_unique'>, 1090),
  (<type 'sage.rings.finite_rings.integer_mod.IntegerMod_int'>, 21566),
  (<class 'weakref.KeyedRef'>, 10447),
  (<type 'builtin_function_or_method'>, 428),
  (<type 'member_descriptor'>, 12),
  (<class
 
'sage.rings.algebraic_closure_finite_field.AlgebraicClosureFiniteField_pseudo_conway_with_category.element_class'>,
   76),
  (<type 'sage.rings.morphism.RingHomomorphism_cover'>, 76),
  (<class 'sage.categories.homset.Homset_with_category'>, 176),
  (<type 'method_descriptor'>, 360),
  (<type 'module'>, 94),
  (<type 'tuple'>, 2688),
  (<type 'sage.libs.pari.gen.gen'>, 60),
  (<type 'sage.structure.coerce_dict.TripleDictEraser'>, 1043),
  (<class 'numpy.testing.nosetester.NoseTester'>, 19),
  (<type 'type'>, 82),
  (<type 'sage.rings.morphism.RingMap_lift'>, 76)]
 sage: test(L, 5)
 []
 }}}

 So, that looks like a different kind of leak: Some objects are not
 deallocated when they aren't used (output of the first `test(L, 5)`), but
 at least they are still available for future use (output of the second
 `test(L, 5)`).

 The patch from this ticket has fixes one leak, and I'd say that the other
 leak should be addressed on a different ticket.

--
Ticket URL: <http://trac.sagemath.org/ticket/18897#comment:31>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to