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
{{ message }}
Repository navigation
Unbounded memory use when specifying otypes='d' in vectorize. #11867
Are you sure there is no leak with your fix? When I tried a test with sys.getrefcount() I find I need to activate the last 2 del statements to make it pass (CPython3 only, CPython2 passes without any deletes). Applying your fix does not change the situation for me. I am using the latest NumPy head.
def test_leaks(self, dels):
class A(object):
def f(self, k):
return 0
def __init__(self):
self.f_vec_otypes = np.vectorize(self.f, otypes='d')
self.f_vec = np.vectorize(self.f)
a_tag = A()
f_refcount = sys.getrefcount(A.f)
for i in range(10):
a = A()
out = a.f_vec_otypes(0)
out = a.f_vec(0)
# del a.f_vec_otypes._ufunc
# del a.f_vec._ufunc
# del a.f_vec_otypes
# del a.f_vec
assert_equal(sys.getrefcount(A.f), f_refcount)
Still playing with it to understand where the extra reference(s) is being created. Adding for i in range(10): gc.collect() influences the refcount number, but does not totally remove the need for the del statements.
Activity
mattip commentedon Sep 3, 2018
Are you sure there is no leak with your fix? When I tried a test with
sys.getrefcount()I find I need to activate the last 2delstatements to make it pass (CPython3 only, CPython2 passes without any deletes). Applying your fix does not change the situation for me. I am using the latest NumPy head.Still playing with it to understand where the extra reference(s) is being created. Adding
for i in range(10): gc.collect()influences the refcount number, but does not totally remove the need for thedelstatements.carlohamalainen commentedon Sep 3, 2018
You're right, the memory usage still grows, just more slowly.
I added one
delto my manual workaround and I see the memory usage (RESin htop) stay constant at 27528:mattip commentedon Sep 7, 2018
vectorizecallsfrompyfunconly in the actual function__call__. I wonder if that is what is creating references that even the GC cannot break.seberg commentedon Jan 9, 2019
Oops, forgot to add/keep a fixes to the commit. This was closed by gh-11977
carlohamalainen commentedon Jan 12, 2019
Thanks @mattip and @seberg :-)