Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak #23

Open
pawel0987 opened this issue Feb 8, 2018 · 3 comments
Open

Possible memory leak #23

pawel0987 opened this issue Feb 8, 2018 · 3 comments

Comments

@pawel0987
Copy link

Invoking fft.FFT() many times for large wav files (~10MB) couses program to panic because of out of memory.
I have tested my program with and without that single line. Without computing fft it occupies ~300MB for very long time. When I enable fft computing it will be 3GB of RAM occupied pretty fast.

@maddyblue
Copy link
Owner

Certainly possible. I don't use this anymore and it was maybe the first Go code I wrote, so it is likely very bad at memory. I'm definitely not going to work on fixing it but I would review a PR.

@J1ng06
Copy link

J1ng06 commented Apr 17, 2020

@pawel0987 I am using this library as well and my app got to 40GB memory usage after running for a few days. The issue is from the fft/bluestein.go: there are two map that caches all the bluesteinFactors and bluesteinInvFactors, which gets larger over time. In my use case, my data set is large as well with different input_len most of the time. Matt's implementation was to speed up the calculation by memorizing the bluesteinFactors and bluesteinInvFactors, but it's not memory friendly. I did some modification for my use case and the calculation slows down, but I don't need to worry about high memory usage anymore.

@i0x71
Copy link

i0x71 commented Jun 29, 2021

@J1ng06 Would you be able to share the modifications that you made to avoid the memory leak ?
Or is it implemented in your fork ?

Much appreciated

ghost referenced this issue in NectGmbH/go-dsp Jan 3, 2023
* Init go module

* Fix bluestein cache memory leak through lfu strategy cache with 64 items:
According to mjibson#23 there is a memory leak bug in the caching of bluestein factors. This addresses this through an lfu cache with a capacity of 64 items. Based on the input length and thus the size of the computed factors this is sufficient.
The max size of the cache can be calculated through:
size_factor = (128*2) / 8 = 32
max_size = size_factor * input_len * 64

E.g.: A 1 sec wav file with sample rate of 44.1 kHz and an arbitrary sample size results in
32 * (1 * 44100) * 64 = 86.13 MByte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants