Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
None
-
5.14.1
-
None
-
-
e0a44ab3c8 (pyside/pyside-setup/dev) e0a44ab3c8 (pyside/tqtc-pyside-setup/dev) e0a44ab3c8 (pyside/tqtc-pyside-setup/tqtc/dev)
Description
Precondition:
- Class with signal
incomingHubsIndices: QtCore.SignalInstance = QtCore.Signal(dict)
- The signal is connected to QML slot
- Sample code is attcahed
- The timer callback method is called from a timer with a 1s period
Result:
Memory leak(video is attached)
Ref count after is greater than before emit
If I try to send Qt object instead of python
incomingHubsIndices: QtCore.SignalInstance = QtCore.Signal(QJsonValue)
def timer_callback(self): test_data = {n: {"TEST" : 123456789} for n in range(50000)} print("before emit" + str(sys.getrefcount(test_data))) qt_object = QtCore.QJsonValue.fromVariant(test_data) self.incomingHubsIndices.emit(qt_object) print("after emit" + str(sys.getrefcount(test_data)))
The memory leak is absent
This code is from my application which I can't share. That's why you can see more RAM usage than just with the sample script.
Python 3.10.6 Qt 6.4.1 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 11.3.0) file:///pyside2098/main.qml:9:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } qt.pyside.libpyside: qtMethodMetacall #6 "on_completed()" Worker.on_completed() qt.pyside.libpyside: qtMethodMetacall #7 "timeout()" #0 Worker.timeout(): before emit: 2 qt.pyside.libpyside: qtMethodMetacall #5 "dictSignal(PyObject)" qml: +++++++++++++++++++++++++++: QVariant(PySide::PyObjectWrapper, 0x7f1180a67440) after emit: 3 qt.pyside.libpyside: qtMethodMetacall #7 "timeout()" #1 Worker.timeout(): before emit: 2 qt.pyside.libpyside: qtMethodMetacall #5 "dictSignal(PyObject)" qml: +++++++++++++++++++++++++++: QVariant(PySide::PyObjectWrapper, 0x7f1180a67400) after emit: 3
Attachments
Issue Links
- relates to
-
PYSIDE-164 Program hangs when emitting a signal with Qt.BlockingQueuedConnection
- Closed
-
PYSIDE-813 Hard crash when emitting signal with argument into QThread
- Closed
For Gerrit Dashboard: PYSIDE-2098 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
441346,1 | WIP: PySide2: Handle dict in signals | tqtc/lts-5.15 | pyside/tqtc-pyside-setup | Status: ABANDONED | 0 | 0 |
441775,5 | Fix passing dicts as QVariantMap to QML | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
441913,1 | WIP: Test QML slots taking QVariantList/QVariantMap | dev | pyside/pyside-setup | Status: ABANDONED | -2 | 0 |