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

QQuickImageProvider Memory Leaks



    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Duplicate
    • Affects Version/s: 5.9.1
    • Fix Version/s: None
    • Labels:



      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:


      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.

      Martin Peniak
      Head of Innovation at Cortexica Vision Systems




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

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.



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



                  Gerrit Reviews

                  There are no open Gerrit changes