Skip to content

BUG: Memory leak in buffer interface with NPY_RELAXED_STRIDES_CHECKING #16934

@peterbell10

Description

@peterbell10

Reproducing code example:

The following cython code leaks memory when called in a loop:

import numpy as np
from cpython.buffer cimport *

a = np.random.rand(10)[:, None]

def memory_leak():
    cdef Py_buffer buf
    PyObject_GetBuffer(a, &buf, PyBUF_STRIDED)
    PyBuffer_Release(&buf)

The key factor seems to be the zero strided axis in a.

Numpy/Python version information:

1.17.2 3.7.7 (default, May  7 2020, 21:25:33) 
[GCC 7.3.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions