#12215: Memleak in UniqueRepresentation, @cached_method
-----------------------------+----------------------------------------------
Reporter: vbraun | Owner: rlm
Type: defect | Status: needs_work
Priority: major | Milestone: sage-5.0
Component: memleak | Keywords: UniqueRepresentation
cached_method caching
Work_issues: Fix two tests | Upstream: N/A
Reviewer: | Author: Simon King
Merged: | Dependencies: #11115 #11900
-----------------------------+----------------------------------------------
Comment(by SimonKing):
I was also tracing the deletion of items of weak value dictionaries: I was
writing the key to a log file whenever an item was deleted.
Already when starting sage, we see that the same key (and presumably the
same value as well) is deleted repeatedly:
{{{
...
((<class 'sage.categories.category.JoinCategory'>, (Category of semirings,
Category of infinite enumerated sets)), ())
((<class 'sage.categories.groupoid.Groupoid'>, Integer Ring), ())
((<class 'sage.categories.groupoid.Groupoid'>, Rational Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Rational Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Rational Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Complex Lazy Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Rational Field), ())
}}}
When issuing the first line of the crashing example and repeating it, we
see something like
{{{
...
((<class 'sage.categories.groupoid.Groupoid'>, Complex Lazy Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Complex Lazy Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Cyclotomic Field of order 4
and degree 2), ())
((<class 'sage.matrix.matrix_space.MatrixSpace'>, Rational Field, 0, 0,
False), ())
((<class 'sage.matrix.matrix_space.MatrixSpace'>, Rational Field, 10, 0,
False), ())
((5, 0, 'prealpha0'), (Rational Field, 0, False, None))
((<class 'sage.matrix.matrix_space.MatrixSpace'>, Rational Field, 0, 0,
False), ())
((<class 'sage.matrix.matrix_space.MatrixSpace'>, Rational Field, 10, 0,
False), ())
}}}
And at crashing, one has
{{{
((<class 'sage.matrix.matrix_space.MatrixSpace'>, Ring of integers modulo
46337, 4, 10, False), ())
((<class 'sage.categories.vector_spaces.VectorSpaces'>, Ring of integers
modulo 46337), ())
((<class 'sage.matrix.matrix_space.MatrixSpace'>, Integer Ring, 4, 10,
False), ())
((<class 'sage.matrix.matrix_space.MatrixSpace'>, Rational Field, 4, 10,
False), ())
((<class 'sage.categories.groupoid.Groupoid'>, Power Series Ring in q over
Rational Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Power Series Ring in q over
Rational Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Power Series Ring in q over
Rational Field), ())
((<class 'sage.categories.groupoid.Groupoid'>, Power Series Ring in q over
Integer Ring), ())
}}}
Conclusion:
The occurring keys indicate that the deletions occur in
`UniqueRepresentation`. While using weak references for
`UniqueRepresentation` fixes memory leaks, it seems that far too often
stuff is removed that would actually still be needed. Certainly it is bad
for speed, and it seems that it is also responsible for the segmentation
faults.
I am not sure how that problem should best be addressed.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12215#comment:69>
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.