Closed
Description
@nadiahpk first encountered this in the way that SciPy's hypergeom
uses vectorize.
Here is a stand-alone example for reproducing the memory behaviour:
import numpy as np
class myclass():
def f_class_method(self, k): return 0
def __init__(self):
self.f_class_method_vec_d = np.vectorize(self.f_class_method, otypes='d')
self.f_class_method_vec = np.vectorize(self.f_class_method)
# Memory use keeps growing:
def main1():
while True:
myclass().f_class_method_vec_d(0)
# Memory use constant:
def main2():
while True:
myclass().f_class_method_vec(0)
# Manual workaround for main1, now has constant memory use:
def main3():
while True:
m = myclass()
m.f_class_method_vec_d(0)
del m.f_class_method_vec_d._ufunc
I believe the issue is that self._ufunc
becomes a circular reference when the function being vectorized is a class method.
I have a workaround here: carlohamalainen@9b5747b
Metadata
Metadata
Assignees
Labels
No labels