Memory leak under OsX when using overpaint?

  • Hello QT forum,

    I found a pretty strange behaviour when testing my QT app and discovered the same when testing it with the overpainting example:

    I tested the application against memory leaks using Instruments, a tool for mac osx.

    1. When I changed the framerate to 60Hz or higher the memory consumption increased linearly by 1Mb / 60 sec
      2 ) Works fine with a lower framerate. This should not be an issue, or what do you think?
      3 ) Anyway, when calling also updateGL(); before calling update() in order to invoke the paintEvent everything works fine again.

    Does anyone have an explanation for this?

    modified the file: opengl/overpainting/glwidget.cpp
    connect(&animationTimer, SIGNAL(timeout()), this, SLOT(animate()));
    animationTimer.start(16); // changed this from 25ms to 16ms. Sould be roughly 60Hz
    which causes a memory leak.

    However, when adding also updateGL() to the animate function, the memory leak did not occur, ever when beeing updated at 60 Hz:
    void GLWidget::animate()
    QMutableListIterator<Bubble*> iter(bubbles);


    while (iter.hasNext()) {
    Bubble *bubble =;

    When looking at the call stack it looks to me that under OsX a lot of timer objects (NSTimer) are being created nut not destroyed. This happens within update, so at a level where I cannot call delete or release. It seems, that there is a rate for freeing these objetcs and by running my timer to fast a constant number seems to be left behind in the memory, which could explain the constant increase in memory.

    I hope I could make the problem clear and hope to get some interesting comments on this. Moreover, I hope that some people can save some time chasing down this problem.

    Best regards,

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Since the problem goes low level, I would recommend that you post this question on the interest mailing list, you'll find there Qt's maintainers/developers (this forum is more user oriented)

    You could also check the "bug report system": to see whether it's a known issue.

    Adding which version of Qt you are using and which version of OS X would also be helpful

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.