Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.9.3
-
VS2015
Description
testMemory::testMemory(QWidget *parent) : QWidget(parent) { ui.setupUi(this); m_tab = new QTabWidget(this); m_tab->setTabsClosable(true); for (int i = 0; i < 50; ++i) { SubWidget* pWidget = new SubWidget; m_tab->addTab(pWidget, "tab" + QString::number(i)); } connect(m_tab, SIGNAL(tabCloseRequested(int)), this, SLOT(slot_close(int))); QVBoxLayout* vLayout = new QVBoxLayout(this); vLayout->addWidget(m_tab); } void testMemory::slot_close(int p_nIndex) { if (m_tab != NULL) { // m_tab->removeTab(p_nIndex); QWidget* widget = m_tab->widget(p_nIndex); if (NULL != widget) { delete widget; widget = NULL; // widget->close(); } } }
As above, I created 50 SubWidgets inherited from QWidget and added them to the QTabWidget. When i closed a tab and deleted the SubWidget, Through the task manager and performance monitor of win10, there is basically no change in memory. I repeated the above operation after a while, but the result is still the same. It means that the memory has not been released. So i want to know why and look forward to your reply.