mpc
mpc copied to clipboard
SoundRecorder hogs memory unnecessarily
In the .hpp
we do:
const uint32_t INTERNAL_BUF_SIZE = 100000;
std::vector<float> leftChannelCopy = std::vector<float>(INTERNAL_BUF_SIZE);
std::vector<float> rightChannelCopy = std::vector<float>(INTERNAL_BUF_SIZE);
circular_buffer<float> ringBufferLeft = circular_buffer<float>(INTERNAL_BUF_SIZE);
circular_buffer<float> ringBufferRight = circular_buffer<float>(INTERNAL_BUF_SIZE);
std::vector<float> unresampledLeft = std::vector<float>(INTERNAL_BUF_SIZE);
std::vector<float> unresampledRight = std::vector<float>(INTERNAL_BUF_SIZE);
std::vector<float> resampledLeft = std::vector<float>(INTERNAL_BUF_SIZE);
std::vector<float> resampledRight = std::vector<float>(INTERNAL_BUF_SIZE);
This amounts to 3.2MB of RAM allocation. This is only necessary when actually recording, so let's not allocate it for the lifetime of the application, but only when recording.