Skip to content

BUG: Memory leaks in numpy.nested_iters #19400

@Stardust1225

Description

@Stardust1225

This code is generated by a fuzzing testing tool, and I find that the memory use is increasing as the times of calls.

Reproducing code example:

import sys
import tracemalloc
import numpy

memory_recorder = []
tracemalloc.start()
start_snapshot = tracemalloc.take_snapshot()
for i in range(0, 1000):
    try:
        numpy.nested_iters(['e', 'f'], [[1], [2]])
    except: pass
    if i % 100 == 0:
        one_snapshot = tracemalloc.take_snapshot()
        memory_recorder.append(one_snapshot.compare_to(start_snapshot, 'lineno')[0])

for i in range(1, len(memory_recorder)):
    print(memory_recorder[i].traceback)
    print(memory_recorder[i].size)
    print()

tracemalloc.stop()

Error message:

..py:15
16160

..py:15
32160

..py:15
48160

..py:15
64160

..py:15
80160

..py:15
96160

..py:15
112160

..py:15
128160

..py:15
144160

NumPy/Python version information:

In commit 6d9e294
Date: Thu Jul 1 09:42:16 2021

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - BugsprintableIssue fits the time-frame and setting of a sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions