Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.15.15
Description
A reproducer:
main.cpp:
#include <QGuiApplication> #include <QQmlApplicationEngine> #include <QQuickImageProvider> #include <QQuickWindow> class ImageProvider: public QQuickImageProvider { public: ImageProvider():QQuickImageProvider(QQuickImageProvider::Image) ,image(100, 100, QImage::Format_RGB888) { image.fill(Qt::black); } QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) override { *size = image.size(); return image; } QImage image; }; int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //Switch between OpenGL and OpenGLRhi to see difference QQuickWindow::setSceneGraphBackend(QSGRendererInterface::OpenGL); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.addImageProvider("ImageProvider", new ImageProvider()); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }
Main.qml:
import QtQuick 2.15 import QtQuick.Window 2.15 Window { id: root width: 640 height: 480 visible: true property int counter Timer { running: true repeat: true interval: 5 onTriggered: { counter++ if (10000 < counter) { counter = 0 } } } Column { Repeater { id: _repeater model: 100 delegate: Image { id: img cache: false source: "image://ImageProvider/" + (counter + index) } } } }
Judging from system monitor, OpenGLRhi backend eats up to ~700 MB memory while OpenGL only consumes ~40 MB. The difference is absolutely not normal.
However, I do not use the word "memory leak" here since I did memory check using Valgrind. Although there are reports about leaks, but no significant difference between the results from OpenGLRhi and OpenGL. So I don't think OPenGLRhi causes memory leak but OpenGL does not. Please find the attached result.
The behavior is quite similar to:
QTBUG-95132
which also reports a "memory leak" about Rhi backend, which is not an actual memory leak. But QML Image is not a QQuickPaintedItem so I am not sure if they are the same issue.
Finally, the problem cannot be reproduced with latest 6.5.3, although it is all Rhi. So will the problem be fixed for 5.15? I am concerned since 5.15 is in strict mode and probably won't receive anything other than security patch? If so, any workaround to suppress memory usage while still keep Rhi backend?