-
Notifications
You must be signed in to change notification settings - Fork 107
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 when using nogil Cython #51
Comments
I did a valgrind run with only two outer loop iterations and two inner loop iterations ( The result is 26 MB of leaked memory. Those mostly comes from those 2 numpy allocations:
Maybe there is a ref counting problem on those numpy arrays? |
This Cython method is called by Python code. The leaked returned array values are explicitly dereferenced by |
@colesbury I think I can try to craft a standalone reproducer based on the analysis above if you need. |
@ogrisel thanks for the bug report. Looks like I messed up the patch to Cython memory views. |
I had accidentally introduced a memory leak when addressing the thread-safety issue in #50. It's fixed now: You'll need to re-install Cython and re-build scikit-learn:
There may still be a much smaller memory leak that I haven't tracked down yet. |
I confirm it works!
Thanks very much for the quick fix! |
Code to reproduce:
Using nogil-Cython build of scikit-learn: CPython
Using scikit-learn installed from conda-forge
Note: this code is using OpenMP-based threading but the leak still happens when disabling the OpenMP threading layer by setting
OPENMP_NUM_THREADS=1
so this problem is probably not related to OpenMP.Note sure how to debug this. Maybe I could try to use valgrind.
The text was updated successfully, but these errors were encountered: