Hi,

I have realised that I cannot release all the memory allocated by a huge 
QJsonObject when I don’t need it any more. To ensure that nothing else was in 
between I have created a simple program that does what is below. Conclusion:

- Running on a Mac, compiled in release with Qt 6.5.3

- Starts with 31.7 MB



- Goes up to 412.5 MB



- After calling uncreate drops to 42.7




If I repeat this procedure, it always increases the process memory size 
although it is not linear.

In iOS the problem is even worse.

Any ideas of what is happening here?

Thank you!

Best regards,

Nuno


QString GetRandomString()
{
    const QString 
possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
    const int randomStringLength = 4096; // assuming you want random strings of 
12 characters
    
    QString randomString;
    for(int i=0; i<randomStringLength; ++i)
    {
        int index = QRandomGenerator::global()->generate() % 
possibleCharacters.length();
        QChar nextChar = possibleCharacters.at(index);
        randomString.append(nextChar);
    }
    
    return randomString;
}

void Controller::create()
{
    qDebug() << Q_FUNC_INFO;

    for (int i=0; i<100000; i++)
        _data[QString::number(i)] = GetRandomString();
}

void Controller::uncreate()
{
    qDebug() << Q_FUNC_INFO;

    _data = QJsonObject();
}


_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to