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 np.random.choice with replace = False #14169
Comments
In case you are interested in that, but |
Is this still a problem? |
@charris, yes, for the legacy random interface, it still is: Line 979 in ba4e4b6
The recommended way to avoid the problem is to do what @seberg suggested in a comment last year: use the new API that was introduced in 1.17. It doesn't have this problem:
In theory, we could fix the old code by making a copy after slicing, but at this point, I don't think we should bother. If it isn't crashing Python, our policy has been to not touch the old code. |
Closing as a "won't fix" and removing the milestone. Please undo if I am mistaken. |
When using choice with an integer arg, the choice function creates a randomised array with np.permutations then returns a slice of this array. This keeps the big array in memory instead of just size elements. The choice function should return a copy of the slice to decrement the ref count of the temporary array.
Numpy/Python version information:
Tested in 1.16 but I did not find a fix in the master.
The text was updated successfully, but these errors were encountered: