You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling a function with a const pybind11::array& argument appears to leak refcounts to some Python object. However, it's not the object passed in nor there is a memory leak, so possibly the refcount of some global singleton is not decremented properly.
Numpy itself has a known refcount leak (numpy/numpy#8503), but only with dtype=object arrays --- which are not involved in the case below. Unless, pybind11 uses numpy object arrays internally?
The leaking refcount seems to be that of a dtype singleton.
Reproducible example code
Python debug build is needed for sys.gettotalrefcount(), but you can see the dtype leak also on normal Python:
PyArray_DescrFromType returns a new reference. Changing this to steal fixes the refcount leak.
pv
changed the title
sys.gettotalrefcount() increases with pybind11::array argument
pybind11::array argument leaks reference count of dtype singleton
Jul 24, 2019
Issue description
Calling a function with a
const pybind11::array&
argument appears to leak refcounts to some Python object. However, it's not the object passed in nor there is a memory leak, so possibly the refcount of some global singleton is not decremented properly.Numpy itself has a known refcount leak (numpy/numpy#8503), but only with dtype=object arrays --- which are not involved in the case below. Unless, pybind11 uses numpy object arrays internally?The leaking refcount seems to be that of a dtype singleton.
Reproducible example code
Python debug build is needed for
sys.gettotalrefcount()
, but you can see the dtype leak also on normal Python:gives here (same for pybind11 2.3.0 and 4a3464f; numpy 1.16.4 or current master)
The text was updated successfully, but these errors were encountered: