Menu

#22 Memory leak in MapControl::paintEvent

0.9.8.0
closed
Memory Leak (2)
6
2015-04-13
2015-01-14
No

If the width or height changes this leaks memory. You need to check if doubleBuffer exists and call delete before you create the new pixmap.

    static QPixmap *doubleBuffer = 0;
    if (!doubleBuffer || doubleBuffer->width() != width() || doubleBuffer->height() != height())
    {
       doubleBuffer = new QPixmap(width(), height());
    }

Discussion

  • Brad Grimmett

    Brad Grimmett - 2015-01-20
    • labels: --> Memory Leak
    • status: unread --> open-accepted
    • assigned_to: Brad Grimmett
    • Priority: 5 --> 6
     
  • Brad Grimmett

    Brad Grimmett - 2015-01-23

    Thanks mate. patched in latest commit r62

     
  • Brad Grimmett

    Brad Grimmett - 2015-01-23
    • status: open-accepted --> closed
     
  • Gerard GAUDEAU

    Gerard GAUDEAU - 2015-01-29

    Why did you use a static buffer ?
    If they are two QMapControl components with two different dimensions, that occurs two delete-new allocation at every paintEvent call.

     
  • Brad Grimmett

    Brad Grimmett - 2015-02-11

    you're absolutely right! no need to be static, i'll correct in next merge.

    re-opening bug

     
  • Brad Grimmett

    Brad Grimmett - 2015-02-11
    • status: closed --> open-accepted
     
  • Gerard GAUDEAU

    Gerard GAUDEAU - 2015-02-13

    Please notice that when we produce multiple instances of MapControl, it could generate some failures with ImageManager Singleton.

    For example, in __init() method of MapControl, you make connections between ImageManager and MapControl instance. The signal imageReceived() is emitted twice to each MapControl if you instanciate two MapControl. Then we are four signals emitted instead of two.

    Good luck.

     
  • Brad Grimmett

    Brad Grimmett - 2015-04-13

    sorry for the long delay, I've been super busy at work

    fixed up in latest commit; also addressed singleton issues with multiple instances of the widget

    cheers

     
  • Brad Grimmett

    Brad Grimmett - 2015-04-13
    • status: open-accepted --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB