Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
6.8.1, 6.9.0 Beta1
-
None
-
Ubuntu 24.04
-
-
5aad93503 (dev), e8b924bec (6.9), d29f95dfb (6.8)
Description
A coworker of mine discovered a memory leak in QJSEngine. Here is a simple test program:
/* * Demonstrate a memory leak in QJSEngine. * * Build with: * qmake -project -o TestQJSEngine.pro * echo 'QT += qml' >> TestQJSEngine.pro * qmake TestQJSEngine.pro * make */ #include <QCoreApplication> #include <QJSEngine> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QJSEngine interpreter; QJSValue result; for (int i = 0; i < 1e7; i++) result = interpreter.evaluate("2+2"); qDebug() << "Result is: " << result.toNumber(); }
Running under Qt 6.6.3, this program has a memory consumption (as reported by ps -o rss) that is quite stable, at around 16 MiB. Under Qt 6.8.1, however, the same program grows in size linearly in time, reaching close to 15 GiB.
Here is a graph showing the RSS memory size as a function of time during the whole execution. Mind the logarithmic scale!
Edit: fixed the horizontal scale on the graph.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-132931 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
620375,7 | QJSEngine: Trim compilation units after evaluating a program | dev | qt/qtdeclarative | Status: NEW | 0 | 0 |
618260,3 | QJSEngine::collectGarbage: Align behavior with QML's gc method | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
619021,2 | QJSEngine::collectGarbage: Align behavior with QML's gc method | 6.9 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
619284,2 | QJSEngine::collectGarbage: Align behavior with QML's gc method | 6.8 | qt/qtdeclarative | Status: MERGED | +2 | 0 |