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]