-
-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memory leak in scalar*vector multiplication #10262
Comments
comment:2
FWIW, I've found when building on Solaris with a special library for memory allocation, which allows leaks to be detected, before I got to the
there was already memory leaked. I think it was only 14 bytes, but once I did a few calculations, more showed up. I think there are quite a few in Sage. Of course, some are more serious than others, but whatever the amount of memory leaked, it shows there's a coding error. Dave |
comment:3
As I mentioned on the thread, I tracked this down to a call from the coercion system to create an element of the parent. The coercion system did this when it was trying to figure out the action of the number on the vector: The problem seems to stem from the lines
inside of the
|
comment:4
Replying to @jasongrout:
So My guess is that "an_element()" gets memoised, and retained instead of being destroyed at each for-loop. Indeed:
So we get these huge vectors clogging up the memory, in hope that someone might want to compute in the free modules (over ambient_pid_with_category) of these dimensions again... Should one just turn the memoisation for modules off completely? |
comment:5
Why is this a blocker? |
comment:6
Replying to @jdemeyer:
it is not, indeed. After investigating what happens, I forgot to change it to major, sorry. |
comment:7
This might also be related to #10570 since that ticket shows that there are call stack frames in the coerce_actions framework which stay alive for some reason. |
Attachment: 10548-coerce-traceback-doctest.patch.gz |
comment:9
sorry uploaded a patch to the wrong ticket |
comment:12
Replying to @dimpase:
At least with #14711, the parent and its cached elements appear to be correctly destroyed after each loop turn. However, calling
Possible quick fix, with some code duplication: diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py
index a61b433..81a626c 100644
--- a/src/sage/modules/free_module.py
+++ b/src/sage/modules/free_module.py
@@ -4409,6 +4409,14 @@ class FreeModule_ambient(FreeModule_generic):
"""
return self
+ def gen(self, i):
+ if i < 0 or i >= self.rank():
+ raise ValueError, "Generator %s not defined."%i
+ v = self.zero().__copy__()
+ v[i] = self.base_ring()(1)
+ v.set_immutable()
+ return v
+
def basis(self):
"""
Return a basis for this ambient free module. But I am not convinced it is such a good idea in general to cache the basis of a |
comment:13
Turns out there is already a more polished version of the fix I was suggesting at #13304. |
Dependencies: 13304 |
comment:15
perhaps this ticket should at least provide a doctest that this issue is fixed by #13304? |
Changed dependencies from 13304 to #13304 |
Here is an example
The printed numbers in Mb. Needless to say:
works as expected. (This is with Sage 4.6 on x64, but is not limited to this particular platform: see https://groups.google.com/group/sage-devel/browse_thread/thread/e86f13c78b92a8bb?hl=en. Sage 4.5.3 shows the same behaviour.)
Depends on #13304
CC: @koffie
Component: linear algebra
Issue created by migration from https://trac.sagemath.org/ticket/10262
The text was updated successfully, but these errors were encountered: