My app gets WMI data and displays it as QTreeWidgetItem, but it consumes to much RAM memory when changing languages.
void MyApp::appOSThread()
{
try {
osWorker = new Worker();
osThread = new QThread(osWorker);
osWorker->moveToThread(osThread);
connect(osThread, &QThread::started, osWorker, &Worker::appOSWMIData);
connect(osWorker, &Worker::appOSData, this, &MyApp::osWMIData);
connect(osWorker, &Worker::hardwareDataNotAvailable, this, &MyApp::osWMIDataNotAvailable);
connect(osWorker, &Worker::errorNotSupportedOS, this, &MyApp::appNotSupportedOS);
connect(osWorker, &Worker::finished, osThread, &QThread::quit, Qt::DirectConnection);
connect(osThread, &QThread::destroyed, osThread, &QThread::deleteLater);
osThread->start();
logData(QObject::tr("Application: gets OS information"));
} catch (...) {
QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("An error has occurred with detecting OS!"));
}
}
void MyApp::osWMIData(QStringList property, QStringList data)
{
int countOSProperties = property.count();
QString osProperty;
QString osData;
for (int i = 0; i < countOSProperties; i++) {
osProperty = property.at(i);
osData = data.at(i);
osItem = new QTreeWidgetItem(osView); //osView - QTreeWidget
osItem->setText(0, osProperty);
osItem->setText(1, osData);
}
}
void MyApp::appLocalization()
{
osView->clear();
appOSThread();
}
For example when app is started takes 30 MB when change language then it takes 3 - 5 MB RAM and when changing again it takes again 5 - 10 MB of RAM.
Any ideas?