QWebEnginePage run javascript in loop ,the memory usage is rising



  • i want to get data from webpage on the internet, i use the following code to get the webpage data,

      webView->page()->runJavaScript(read1,[=](const QVariant &V)
            {
    
              
    
                foreach (QVariant good, V.toList()) {
    
                    QMap<QString, QVariant> goodObj= good.toMap();
                    goodIndex++;
                    currentGood.setItem_url(goodObj["item_url"].toString());
                    currentGood.setId(goodObj["id"].toString());
                    currentGood.setTitle(goodObj["title"].toString());
                    currentGood.setSprice(goodObj["sprice"].toFloat());
                    currentGood.setTcount(goodObj["tcount"].toInt());
                    currentGood.setCharge(goodObj["charge"].toFloat());
                    QString tc=goodObj["tcharge"].toString();
                    tc=tc.remove(QChar(','));
                    currentGood.setTcharge(tc.toFloat());
                    currentGood.setCover(goodObj["cover"].toString());
                    currentGood.setCharge2(goodObj["charge2"].toString());
                    currentGood.setFrom_type(goodObj["from_type"].toInt());
                    currentGood.setIs_wap("1");
                    currentGood.setAct_time_end("-1");
                    currentGood.setAct_time_start("-1");
                    currentGood.PushGood();
    
                    sysSetting->setGoodIndex(goodIndex);
                    sysSetting->saveSetting();
                    emit GetNewGood(currentGood.getId());
                    QThread::msleep(30);
                    qDebug()<<goodIndex<<currentGood.getId();
                }
    
                if(pageIndex<=pageCount)
                {
                    pageIndex++;
                    sysSetting->setPageIndex(pageIndex);
                    sysSetting->saveSetting();
                }
                getGoods();
    
    
            });
    

    and i can get the data , because there is a lot of pages to get the data ,so i run this function in a loop,as time goes by ,the memory usage of the QtWebEngineProcess.exe use a lot of memory , how can i solve this problem?



  • I also have the memory issue. If the loaded website has many ajax request, the memory of the qwebengineprocess.exe keeps rise up which will up to 99% memory of the OS or cause the OS to be crashed. I'm using win7 x64. I checked qt 5.9.2 and qt 5.10. They all have the same issue.



  • the crashed issue may be reproduced when the qtwebengineprocess.exe runs the website more than 10 minutes. The long time it runs, and the high memory it takes. It seems the memory is not recycled which cause this issue.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.