-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: memory leak on numpy.linalg.solve
#27629
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
Comments
If you guys think it is a problem, I would love to figure out how to solve this leak and contribute to this project. |
I wonder if there's a reference counting bug. It would be interesting to compile a debug build of Python so you can check that |
Great point, @ngoldbaum. I'll do it ASAP! |
If such simple code had a reference counting bug, a lot bigger things would explode, I imagine. I would suggest just checking the typical thing: run the same thing for much longer or shorter and see if the result and amount leaked is pretty much the same. It seems more likely to me that some caches get initialized once and then re-used. (Either in NumPy or openblas.) |
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
At my job, I was doing some memory analysis on our application in order to identify possible memory leaks.
To do this, I've used the package
memray
, which offers a lot of handy commands to identify memory leaks by generating a flame graphs that identifies memory chuncks allocated after tracking starts and not deallocated after tracking ends.Reproduce the code example:
Error message:
In order to reproduce the analysis, use the following commands:
PYTHONMALLOC=malloc python -m memray run --native test_numpy_leak.py
python -m memray flamegraph --leaks memray-test_numpy_leak.py.XXXX.bin
, whereXXXX
is the number of the file specified in its name.After running these commands, it generates an HTML file, so you can open in your browser and see a flame graph, like the one above. I highlighted in red the section where
memray
reports a memory leak, if I hover it, it says that 4 allocations was made (32.0 MiB in total).The line of code that is leaking memory is the following:
numpy/numpy/linalg/_linalg.py
Line 410 in 41c6bbe
Python and NumPy Versions:
1.26.2
3.11.9 (main, Jul 19 2024, 18:26:46) [GCC 14.1.1 20240522]
Runtime Environment:
No response
Context for the issue:
Actually, I was just worried if this memory leak could scale and do more damage
The text was updated successfully, but these errors were encountered: