Python 调用scipy函数后的内存使用情况
执行每个语句后,请考虑以下代码的内存使用情况:Python 调用scipy函数后的内存使用情况,python,numpy,memory,scipy,signal-processing,Python,Numpy,Memory,Scipy,Signal Processing,执行每个语句后,请考虑以下代码的内存使用情况: import numpy import scipy.signal import gc # memory at this point is ~35mb a = numpy.ones(10**7) b = numpy.ones(10**7) # memory at this point is ~187mb c = scipy.signal.fftconvolve(a, numpy.flipud(b), mode="full") # memor
import numpy
import scipy.signal
import gc
# memory at this point is ~35mb
a = numpy.ones(10**7)
b = numpy.ones(10**7)
# memory at this point is ~187mb
c = scipy.signal.fftconvolve(a, numpy.flipud(b), mode="full")
# memory usage at this point is 645mb
# given that a,b,c take up about 305mb in total, this is much
# larger than expected
# If we delete a,b,c and garbage collect...
del a,b,c
gc.collect()
# ...the memory usage drops to ~340mb which is a drop of 305mb
# (as expected since that is the size of what we deleted)
# but the remaining memory usage is still 340mb
# which is much larger than the starting value of 35 mb
为什么进程使用了这么多额外的内存。fftconvolve函数是否存在漏洞,或者是否有其他解释
站台:
- CPython 3.5.1 x64
- Scipy 0.17.0(Christoph Golke的软件包)
- Numpy+MKL 1.11.0rc1(克里斯托夫·高尔克套餐)
- Windows 8.1 x64