Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
None
-
5.12.9, 5.15.1
-
EWDK2004 and msvc2019 19.27.29111 tools, Windows 10 pro 2004 x64
Description
In QtCreator,Just create a qmake project, simply with ui class:
...... class MainWindow : public QMainWindow ......
Add a private QToolBar member, and one slot:
public slots: void refresh_toolbar(); private: QToolBar *tb; ......
In the MainWindow's constructor, create the tb instance and call refresh_toolbar():
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); tb = new QToolBar(this); addToolBar(tb); refresh_toolbar(); } void MainWindow::refresh_toolbar() { static int gg = 0; QList<QAction*> acts = tb->actions(); tb->clear(); // Here actions's memory is not released! // This should release those actions and free the memory, // Qt-5.9.9-mingw32 does that OK, // Qt-5.12.9-msvc2019 and Qt-5.15.1-msvc2019 leaks memory foreach (QAction* act, acts) { delete act; } for(int i = 0; i < 150; ++i) { int title = gg * 1000 + i; QAction *action = tb->addAction(QString::number(title)); action->setData(i); action->setCheckable( true ); action->setChecked( title % 3 ); } if(gg < 1000) QTimer::singleShot(gg++ ? 10 : 5000, this, SLOT(refresh_toolbar())); } ...
Build and run the program, it's memory usage (see at windows task manager) is growing up......
Qt-5.9.9-mingw32-gcc-9.3-i686 is build from source and not affected.
Qt-5.12.9-msvc2019(19.27.29111)-x86_64 is build from source, Qt-5.15.1-dynamic-msvc2019-x86_64 is from https://github.com/martinrotter/qt5-minimalistic-builds/releases/tag/5.15.1 .
Attachments
Issue Links
- is duplicated by
-
QTBUG-88248 QObject orphaned connections soft-leak
- Closed