8000 Repeatedly calling scipy.signal.resample uses more memory than expected · Issue #12297 · scipy/scipy · GitHub
[go: up one dir, main page]

Skip to content
Repeatedly calling scipy.signal.resample uses more memory than expected #12297
@TimSC

Description

@TimSC

I have code that resamples many audio files using scipy.signal.resample. The code uses much more memory than I would expect to the point of freezing the OS. I've managed to simplify my code to a simple test case. This uses ~8Gb RAM after about 6 iterations but I would expect it should use much less memory than this.

I am using inputs of varying sizes, which seems to be significant. If I use an audio input of constant size there doesn't seem to be a problem.

from scipy.signal import resample
import numpy as np

def Test():

	shps = range(11473744, 1000, -2)

	for i, shp in enumerate(shps):
		signal = np.random.normal(size=(shp, 1))

		print (i, signal.shape)
		targetSamples = signal.shape[0]*44100//48000
		signal2 = resample(signal, targetSamples, axis=0)
		print (signal2.shape)
		del signal, signal2

if __name__=="__main__":
	Test()

I might have missed something obvious, so this might not even be a bug!

  • Scipy 1.4.1
  • Numpy 1.18.4
  • Python sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.signal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0