BUG: Memory leaks in numpy.nested_iters#22296
Conversation
tylerjereddy
left a comment
There was a problem hiding this comment.
Taking the core reproducer from the matching issue:
import numpy as np
for i in range(0, 1000):
try:
np.nested_iters(['e', 'f'], [[1], [2]])
except:
passOn main with memory_profiler:
On this feature branch it seems to be identical:
For the original tracemalloc reproducer, this branch does look much better:
/usr/lib/python3.10/tracemalloc.py:547
1256
/usr/lib/python3.10/tracemalloc.py:547
1256
/usr/lib/python3.10/tracemalloc.py:547
1256
/usr/lib/python3.10/tracemalloc.py:547
1256
/usr/lib/python3.10/tracemalloc.py:547
1256
/usr/lib/python3.10/tracemalloc.py:547
1256
/usr/lib/python3.10/tracemalloc.py:547
1256
/usr/lib/python3.10/tracemalloc.py:547
1256
/usr/lib/python3.10/tracemalloc.py:547
1256
whereas on latest main we still leak:
/home/treddy/rough_work/numpy/pr_22296/test.py:10
16160
/home/treddy/rough_work/numpy/pr_22296/test.py:10
32160
/home/treddy/rough_work/numpy/pr_22296/test.py:10
48160
/home/treddy/rough_work/numpy/pr_22296/test.py:10
64160
/home/treddy/rough_work/numpy/pr_22296/test.py:10
80160
/home/treddy/rough_work/numpy/pr_22296/test.py:10
96208
/home/treddy/rough_work/numpy/pr_22296/test.py:10
112208
/home/treddy/rough_work/numpy/pr_22296/test.py:10
128160
/home/treddy/rough_work/numpy/pr_22296/test.py:10
144160
So, this looks solid IMO. I'm not even sure that we'd require a regression test in this case--I suspect not. I do wonder if we could easily add the reproducer from the issue--it runs very quickly, but I'm not so sure we want tracemalloc stuff in our test suite. Cool "idea" from the fuzzer at least.
|
thanks for your first contribution to NumPy |
|
Hi-five on merging your first pull request to NumPy, @clearspear! We hope you stick around! Your choices aren’t limited to programming – you can review pull requests, help us stay on top of new and old issues, develop educational material, work on our website, add or improve graphic design, create marketing materials, translate website content, write grant proposals, and help with other fundraising initiatives. For more info, check out: https://numpy.org/contribute |


Bug fix for this issue: #19400 as part of the Grace Hopper OSD NumPy sprint