Details
-
Bug
-
Resolution: Incomplete
-
P2: Important
-
None
-
5.9.2, 5.15.2, 6.3.1
-
None
Description
In Qt 6.3.1 (msvc2019_64), the following memory leakages occur each time you select an item in a QTreeWidget (for example by clicking on it):
{8370} normal block at 0x000002E0EC7DFD90, 160 bytes long. Data: < > 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 {8369} normal block at 0x000002E0EC7ABBB0, 40 bytes long. Data: < } > 01 00 00 00 01 00 00 00 90 FD 7D EC E0 02 00 00 {8366} normal block at 0x000002E0EC7B6A10, 120 bytes long. Data: <hZ ( > 68 5A 00 CE FB 7F 00 00 10 28 7F EC E0 02 00 00 {8365} normal block at 0x000002E0EC7F2810, 56 bytes long. Data: <H j{ > 48 C9 BF CA FB 7F 00 00 10 6A 7B EC E0 02 00 00 {8323} normal block at 0x000002E0EC7E1990, 160 bytes long. Data: < > 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 {8322} normal block at 0x000002E0EC7AB9F0, 40 bytes long. Data: < ~ > 01 00 00 00 01 00 00 00 90 19 7E EC E0 02 00 00 {8319} normal block at 0x000002E0EC7B6410, 120 bytes long. Data: <hZ # > 68 5A 00 CE FB 7F 00 00 10 23 7F EC E0 02 00 00 {8318} normal block at 0x000002E0EC7F2310, 56 bytes long. Data: <H d{ > 48 C9 BF CA FB 7F 00 00 10 64 7B EC E0 02 00 00
If you hold the mouse button and move up and down in the QTreeWidget, it is possible to leak ~1 MB every ~3 seconds.
The leakages can be demonstrated by creating a plain QTreeWidget with a few items in it. Please see the attached 7z file or the source code below.
DLLs used are:
- platforms/qwindowsd.dll
- Qt6Cored.dll
- Qt6Guid.dll
- Qt6Widgetsd.dll
The same leakages were observed in Qt 5.15.2.
There were similar leakages in Qt 5.9.2 (msvc2015), but here the number and sizes are different:
{26840} normal block at 0x06A53700, 28 bytes long. Data: < |@ |p | \ > DC EB 02 7C 40 EC 02 7C 70 EC 02 7C F0 83 5C 01 {26837} normal block at 0x06A52F68, 28 bytes long. Data: < |@ |p | \ > DC EB 02 7C 40 EC 02 7C 70 EC 02 7C F0 83 5C 01 {26831} normal block at 0x06A53598, 28 bytes long. Data: < |@ |p | \ > DC EB 02 7C 40 EC 02 7C 70 EC 02 7C F0 83 5C 01 {26828} normal block at 0x06A54DC8, 28 bytes long. Data: < |@ |p | \ > DC EB 02 7C 40 EC 02 7C 70 EC 02 7C F0 83 5C 01 {26780} normal block at 0x06A54CA8, 28 bytes long. Data: < |@ |p | \ > DC EB 02 7C 40 EC 02 7C 70 EC 02 7C F0 83 5C 01 {26777} normal block at 0x06A54B88, 28 bytes long. Data: < |@ |p | \ > DC EB 02 7C 40 EC 02 7C 70 EC 02 7C F0 83 5C 01 {26596} normal block at 0x06A54C18, 24 bytes long. Data: < > FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00
Our notes indicate that these leakages were not present in Qt 5.7.0.
Source code:
#include <QTreeWidget> #include <QTreeWidgetItem> #include <QApplication> // Enable memory leakage detection in debug mode #if defined(Q_OS_WIN) && !defined(QT_NO_DEBUG) #define _CRTDBG_MAP_ALLOC #include <crtdbg.h> #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #define new DEBUG_NEW #endif int main(int argc, char *argv[]) { // Enable memory leakage detection in debug mode #if defined(Q_OS_WIN) && !defined(QT_NO_DEBUG) _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); #endif // Create application QApplication app(argc, argv); // Create a QTreeWidget with 10 items QTreeWidget treeWidget; for (int n = 0; n < 10; n++) { QTreeWidgetItem* pItem = new QTreeWidgetItem(); pItem->setText(0, QString("Item %1").arg(n)); treeWidget.addTopLevelItem(pItem); } // Show it treeWidget.show(); app.exec(); return 0; }