Following this thread I have created a simple console application to process sound (send input with high gain to the output). However, I am getting memory leakage that I can not resolve where it comes from. If I comment out the instance my custom class, the problem disappears.
The leakage is always 32 bytes long, regardless of the complexity of my audio class. I know it is not that crucial but I would like to understand why and when it happens.
I use Windows 10 with Visual Studio 2017.
Any help is much appreciated.
Here is the main function and the class I made:
Main.cpp
#include “…/JuceLibraryCode/JuceHeader.h”
#include “audioclass.h”int main (int argc, char* argv)
{
initialiseJuce_GUI();
AudioClass ac; // The custom class I have made
DBG(“press ‘Q’ to stop”);
while (auto c = getchar())
{
if (c == ‘q’ || c == ‘Q’)
{
break;
}
}
shutdownJuce_GUI();
return 0;
}
audioclass.h
#pragma once
#include “…/JuceLibraryCode/JuceHeader.h”class AudioClass : public AudioIODeviceCallback
{
public:
AudioDeviceManager deviceManager;
AudioClass()
{
DBG(“AudioClass”);
deviceManager.initialise(2, 2, nullptr, true);
deviceManager.addAudioCallback(this);
}~AudioClass()
{
DBG(“~AudioClass”);
deviceManager.removeAudioCallback(this);
}void audioDeviceIOCallback(const float** inputChannelData, int numInputChannels, float** outputChannelData, int numOutputChannels, int numSamples)
{
for (int channi = 0; channi < numOutputChannels; channi++)
{
for (int i = 0; i < numSamples; i++)
{
outputChannelData[channi][i] = inputChannelData[channi][i] * 1000;
}
}
}void audioDeviceAboutToStart(AudioIODevice* device)
{
DBG("audioDeviceAboutToStart:\nDevice : " << device->getName() << "\nSampleRate : " << device->getCurrentSampleRate() << "\nBufferSize : " << device->getCurrentBufferSizeSamples());
}void audioDeviceStopped()
{
DBG(“audioDeviceStopped”);
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AudioClass)
};