Memory usage is growing with the iterations
See original GitHub issueDescribe the bug
Memory usage is growing with iterations.
To Reproduce
It should work with any kind of audio file but I can send the considered file if needed.
import librosa
import matplotlib.pyplot as plt
import os
import psutil
def foo():
y, sr = librosa.load("clip_04.wav", sr=22050, offset=600, duration=60)
spec_mag = abs(librosa.stft(y, n_fft=2048, hop_length=1024))
spec_db = librosa.amplitude_to_db(spec_mag)
return 42
def main():
process = psutil.Process(os.getpid())
array = []
for i in range(100):
print(i)
foo()
m = int(process.memory_info().rss / 1024**2)
array.append(m)
plt.figure()
plt.plot(array)
plt.xlabel('iterations')
plt.ylabel('MB')
plt.show()
if __name__ == '__main__':
main()
Expected behavior
Memory usage should be constant.
Screenshots
Software versions
Darwin-19.6.0-x86_64-i386-64bit
Python 3.7.9 (default, Aug 31 2020, 07:22:35)
[Clang 10.0.0 ]
NumPy 1.19.5
SciPy 1.5.2
librosa 0.8.0
INSTALLED VERSIONS
------------------
python: 3.7.9 (default, Aug 31 2020, 07:22:35)
[Clang 10.0.0 ]
librosa: 0.8.0
audioread: 2.1.8
numpy: 1.19.5
scipy: 1.5.2
sklearn: 0.23.2
joblib: 0.17.0
decorator: 4.4.2
soundfile: 0.10.2
resampy: 0.2.2
numba: 0.51.2
numpydoc: None
sphinx: None
sphinx_rtd_theme: None
sphinxcontrib.versioning: None
sphinx-gallery: None
pytest: None
pytest-mpl: None
pytest-cov: None
matplotlib: 3.2.2
presets: None
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Why my memory keeps increasing at every iteration? - vision
If you are seeing an increase in the memory usage in each iteration, check if you are storing any tensors, which might be...
Read more >PHP memory usage in For loop keeps growing - Stack Overflow
Increasing memory usage in PHP is normal. unsetting a variable doesn't immediately free up the memory it was taking, it simply marks it...
Read more >Hunting Down Memory Issues In Ruby: A Definitive Guide
What may not be intuitive is why memory usage continues to grow after the first iteration. After all, it built a big array,...
Read more >How to Write Memory Efficient Loops in Python - Medium
In python, when you build a list of numbers, images, files, or any other object that you want to iterate through, you're essentially...
Read more >VI Memory Usage - NI - National Instruments
Functions that generate data take care of allocating the storage for that data. When data is no longer being used, the associated memory...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll try to use
soundfile.read()
with offset and duration constraints. I’ll post here the results of my findings. Thanks again for helping me on this.Hello @bmcfee, I’ve used the code you’ve sent to read the wav file and here are my findings: