Results 1 to 7 of 7

Thread: Out of graphic memory - application crash after days

  1. #1
    Join Date
    Oct 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Out of graphic memory - application crash after days

    Hi all,

    I've designed a program, which shall run 24/7 for several days in order to read some input sensors and update the drawings on my screen. The program two modes, 'config' and 'active'. In the first mode (no inputs read, no graphical update needed), it can run for some weeks without issue. In the 'active' mode it crashes after appr. two days. In the 'active' mode, the program reads the inputs and calls the paintevents.

    I've stripped the code down and attached it as a seperate file. Attachment 12180

    Some explanation to the program structure:
    - I wrote an imagecontroller, which loads all required pictures in a QMap of QPixmaps. From there on, all pictures are referenced by a unique id. (QImageController.*pp). This image controller exits only once in the program.
    - The 'viewData' class represents a child of abstract class 'genericViewPage' which is a specialized QWidget to draw on. ViewData provides a background picture, which is used in fullscreen, and a QList of 'elementRect' as dynamic content elements.
    - 'elementRects' class has a list of 'elementStates' and chooses the current elementState based on the state of the sensor input.
    - 'elementState' class is a representation based on a picture and/or text.

    This is how the program should work: (and mainly does)
    - When starting the program, the imagecontroller loads all required QPixmaps in a QMap. (function addFile(...) )
    - The program changes into the 'active' mode.
    - From now on the program reads the sensor inputs and calls the 'repaintRequest(...)' of the viewData.
    - In 'paintevent()', viewData paints the background and calls the paintevent of the parent (genericviewpage)
    - genericPageview repaints all elements in the list (function drawMe(...)).
    - Each element asks the current elementState to get a pixmap to draw (function getImage(...)).
    - The elementState gets a QPixmap from the Imagecontroller (function getPixmap(...)) and copies it into the required sized qpixmap. If necessary it writes text into it and returns.

    This paint process seems to use more and more graphical memory without releasing any/or all. So I end up with not loading images after some hours and eventually a crashing program.
    I've tried several ways to get the issue fixed but didn't get it. So I would appreciate, if someone can have a second look and let me know, what am I doing wrong here???

    Thanks a lot. Oh, and please let me know, which information you would need to help with the issue.

    Dirk

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Out of graphic memory - application crash after days

    The attachment link seems to be invalid.

    From the sound of it you are leaking memory, like having unmatched new/delete, or you are keeping memory around that you actually don't need anymore.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Out of graphic memory - application crash after days

    yeah, sounds like that to me too. However, I cannot find, where the issue comes from. Do you have any suggestions?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Out of graphic memory - application crash after days

    Check if all new are paired with delete, check if you store things in a map or hash and maybe never remove anything.

    You can also disable certain code, e.g.not do anything for updates and see if that does not increase memory.
    Then the leak must be in the update handling and so forth.

    Ideally of course you'd use a leak checker, not sure if Windows has something like Vagrind for Unix systems.

    Maybe the clang address sanitizer if you can build with clang.

    Cheers,
    _

  5. #5
    Join Date
    Jul 2008
    Posts
    407
    Thanks
    9
    Thanked 52 Times in 50 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Out of graphic memory - application crash after days

    Hi, I often used Visual Leak Detector together with Visual Studio.

    Ginsengelf

  6. The following user says thank you to Ginsengelf for this useful post:

    anda_skoa (17th October 2016)

  7. #6
    Join Date
    Oct 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Out of graphic memory - application crash after days

    Quote Originally Posted by anda_skoa View Post
    The attachment link seems to be invalid.
    Oh, just saw that the code is not readable. Let me link the file once more: QPainter_Issue.cpp

    Thx.

    Dirk

  8. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Out of graphic memory - application crash after days

    My guess would be QImageController::_images growing endlessly.

    Cheers,
    _

Similar Threads

  1. Superposition when displaying Qt Graphic application on embedded Linux
    By requinham in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 25th April 2012, 07:17
  2. Replies: 2
    Last Post: 7th September 2011, 13:12
  3. Replies: 4
    Last Post: 22nd July 2011, 10:42
  4. Replies: 3
    Last Post: 29th April 2010, 15:18
  5. Memory allocation failure and crash in QVector
    By ashatilo in forum Qt Programming
    Replies: 16
    Last Post: 20th October 2007, 23:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.