Variable size FFT?


What’s the best way to have a variable size FFT in JUCE?
Currently I have an FFT using a scoped pointer…

And then when I want to change the size:

However I think this is causing some memory leaks in my plugin so what would be a better way of doing this?


Don’t “think” you are getting memory leaks, test/measure it properly. The JUCE FFT class has the memory leak detector enabled, so you should be getting an assertion during debugging about leaked objects when shutting down your app/plugin if you actually leak.


Question: assuming the FFT is a scoped pointer that we’ve changed using his method, can we just set fft = NULL in the deconstructor to avoid any nonsense?


Yes, but your code likely has some problem if it can’t tolerate the ScopedPointer deleting the held object when it goes out of scope. (A big point of the smart pointers is that you can avoid doing manual calls to delete or nulling them manually.)