Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPA: memory leaks in platform integrations like qminimal and others
Forum Updated to NodeBB v4.3 + New Features

QPA: memory leaks in platform integrations like qminimal and others

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 194 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AnatoliyS
    wrote on last edited by
    #1

    Goal
    We would like to use QMinimal QPA for our project. We run our application on the server without any physical screens.
    We also use address sanitiser to prevent memory leaks.

    Problem
    We noticed, there are a number of memory leaks happening in plugins code.

    For example, there:
    https://github.com/yinyunqiao/qtbase/blob/master/src/plugins/platforms/minimal/qminimalintegration.cpp#L50

    QMinimalIntegration::QMinimalIntegration()
    {
        QMinimalScreen *mPrimaryScreen = new QMinimalScreen();
    
        mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320);
        mPrimaryScreen->mDepth = 32;
        mPrimaryScreen->mFormat = QImage::Format_ARGB32_Premultiplied;
    
        mScreens.append(mPrimaryScreen);
    }
    

    We create pointer QMinimalScreen *mPrimaryScreen and allocate memory that will never be deallocated. The same happens in linuxfb, for example.
    For some reason there's no destructor for this class.

    Question

    1. Why don't we have destructors that would free this memory?
    2. Is it possible to come up with some workaround, so that in our code we could do free this memory manually?

    We tried to do something like

    QList<QScreen*> list = QGuiApplication::screens();
      for (auto screen : list) {
        delete screen;
      }
    

    But it doesn't work, because deleting forward-declared object lead to unpredicted behaviour, and it seems there's no way to downcast it to QMinimalScreen.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      @AnatoliyS said in QPA: memory leaks in platform integrations like qminimal and others:

      But it doesn't work, because deleting forward-declared object lead to unpredicted behaviour

      Can you explain this? QScreen has a virtual dtor so I don't see any problem here.

      And since you instantiate QMinimalIntegration only once it's not much of a problem (although it should be fixed - please create a bug report about this).

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved