Details
-
Bug
-
Resolution: Incomplete
-
P2: Important
-
5.12.2
-
Windows
Description
We have an QQuickWidget class, which its object sometimes could be created and deleted dynamically pretty frequently - Menus and popups for example.
Its source is set to a qml file at construction.
class MyWidget: public QQuickWidget { MyWidget::MyWidget(QQmlEngine* engine) : QQuickWidget(engine, nullptr) { setSource(QUrl("qrc:/qml/components/myMenu.qml")); ...... } ...... }
We noticed that the memory usage has slightly increasing trend overtime by repeatedly create MyWidget,
After checking, this memory issue is from setSource - Looks like after an object is deleted, it's not cleared from QML engine and still stay in some caches?
Reproduce ;
- Start any memory tool (in-code memory usage record like psutil, or external analysis valgrind, heob)
- Construct any QQuickWidget with setSource call
- Delete the object after 3~5 seconds (the time doesn't really matter)
- Repeat step 2 and 3 in a loop for a significant amount of time, like ~5 hours.
Expected :
- Memory consumption not increasing, stay at a flat level.
Actual:
- Memory consumption has minor increasing trend
- From heap analysis, that increasing is due to allocation by setSource call.
Note:
- After some workaround by simply avoid repeatedly creating/deleting QQuickWidget , memory consumption no longer increase.
Attachments
Issue Links
- depends on
-
QTBUG-88248 QObject orphaned connections soft-leak
- Closed
- relates to
-
QTBUG-86368 QQmlContext leak when connecting to and destroying dynamically created object
- Closed