Q:

Qt memory management. What's wrong?

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?

A:

After first call of QImage img("1.png") Qt loads image formats plugins, and leaves them loaded after use (for performance issues). So part of memory that's left is from loaded plugins, and it's not a leak. 
Where do you allocate those QImages (img...img9 case)? Are you sure that they go out of scope?
Remember that OS doesn't always retain memory immediately after freeing it by your software.

