Hello everyone!
I have a question about memory leaks in Qt.
I have a QMainWindow with 2 QPushButtons.
First button click signal:
m_label = new QLabel(this);
QPixmap pix(this->size());
QPainter painter;
painter.begin(&pix);
QImage img("1.png");
painter.drawPixmap(this->rect(), QPixmap::fromImage(img));
m_label->setPixmap(pix);
painter.end();
Secont button click signal:
delete m_label;
When I start my test application the allocated memory is about 11900 Kb When I click on first button then allocated memory for app is about 12450 Kb When I click on the second button I got allocated memory about 12250 Kb
Why I didn't get the same 11900 Kb? Is this a leak?
So if to write the following code:
QImage img("1.png");
QImage img1("1.png");
QImage img2("1.png");
QImage img3("1.png");
QImage img4("1.png");
QImage img5("1.png");
QImage img6("1.png");
QImage img7("1.png");
QImage img8("1.png");
QImage img9("1.png");
Then allocated memory grows but doesn't decrease. Why? How to clean this memory leak?