Okay I found the culprit in an unexpected corner.
I decided to completely strip it to the absolute bare minimum:
int main(int argc, char *argv[])
{
QCoreApplication app (argc, argv);
// initialization
Sms_notifier notifier(true, 5);
notifier.notify(
"+0123456789",
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. ");
qWarning() << "done, looping";
while(true)
{
QCoreApplication::exec();
}
}
Sms_notifier::Sms_notifier(bool test, int interval_length_milliseconds)
: QObject (NULL)
,m_test (test)
,m_interval_length_milliseconds(interval_length_milliseconds)
,m_manager ()
,m_timer ()
,m_addressee()
,m_payload()
{
m_timer.setSingleShot(true);
QObject::connect(&m_manager, &QNetworkAccessManager::finished,
this, &Sms_notifier::on_nam_finished);
QObject::connect(&m_timer, &QTimer::timeout,
this, &Sms_notifier::on_timer_elapsed);
}
Sms_notifier::~Sms_notifier()
{
}
bool Sms_notifier::notify(
const std::string addressee,
const std::string payload
)
{
m_addressee = addressee;
m_payload = payload;
return notify();
}
bool Sms_notifier::notify()
{
QNetworkRequest request;
QByteArray data;
m_manager.post(request, data);
return false;
}
void Sms_notifier::on_nam_finished(QNetworkReply* reply)
{
QNetworkReply::NetworkError error = reply->error();
reply->deleteLater();
if (error != QNetworkReply::NetworkError::NoError)
{
m_timer.start(m_interval_length_milliseconds);
}
else
{
qWarning() << "success";
m_addressee.clear();
m_payload.clear();
}
}
void Sms_notifier::on_timer_elapsed()
{
notify();
}
It turns out it was still leaking while there was no network. So I stripped away all libraries that were linked, and it still leaked.
Eventually my eye struck this in the .pro file:
QMAKE_CXXFLAGS += -fsanitize=address
QMAKE_CFLAGS += -fsanitize=address
QMAKE_LFLAGS += -fsanitize=address -lasan
This was added to detect memory leaks and report them when the application quits. After removing this, the excessive "memory leak" was gone.
I am assuming that the address sanitizer allocates memory for each allocation done by the application, for its own administration purposes. I suspect that when the application releases the allocated memory, the sanitizer holds on to the respective administration data until the application quits. This could explain why when I remove the sanitizer it also removes the leak.
Well, thanks everyone for your input!