Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62600

QQuickImageProvider Memory Leaks

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.9.1
    • None

    Description

      Hi,

      I am developing a cross-platform applications that receives images via REST interface on the C++ side and then sends them to QML via ImageProvider, which seems to be responsible for leaking memory. The speed at which the memory leaks is proportional to the size of the image and update interval. I tried disabling caching of QML Image but did not change a thing. I also tried forcing garbage collection by running gc() on image updates but still no luck.

      To be completely sure that this is not something caused by my bad coding, etc. I have created a minimal demo, which is based on this Qt example:

      http://doc.qt.io/qt-5/qquickimageprovider.html

      The only addition is that I have increased the image sizes and implemented means of swapping the red coloured image for the yellow coloured image.

      Once you run the application the image will change colour every second and the memory will keep increasing. The image has 10000x10000 dimension such that you can see the increase clearly. Even if the image is 10x10 or any other size the memory leak still occurs.

      I have managed to replicate this problem on Android phone, Macbook as well as a PC running Fedora. 

      Please let me know if you see any reason why this is occurring and if it is a bug what workaround I can use to send images to QML. I need to send these images as soon as they are received via REST API so usually around 30FPS.

      Any help will be very much appreciated! The complete solution is attached. Both the Image and Pixmap providers cause the same issue. If you want to test the original Qt code then change QQuickImageProvider::Image QQuickImageProvider::Pixmap in the main.cpp.

      Regards,
      Martin Peniak
      Head of Innovation at Cortexica Vision Systems

       

       

      Attachments

        1. imageProvider.cpp
          1 kB
          Martin Peniak
        2. imageProvider.h
          0.6 kB
          Martin Peniak
        3. main.cpp
          1 kB
          Martin Peniak
        4. main.qml
          0.3 kB
          Martin Peniak
        5. memoryLeakDemo.pro
          1 kB
          Martin Peniak
        6. qml.qrc
          0.1 kB
          Martin Peniak
        7. qtquickcontrols2.conf
          0.3 kB
          Martin Peniak

        Issue Links

          Activity

            People

              srutledg Shawn Rutledge
              mpeniak Martin Peniak
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: