Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Who takes care of deleting QImage returned from QQuickImageProvider?
Forum Updated to NodeBB v4.3 + New Features

Who takes care of deleting QImage returned from QQuickImageProvider?

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.8k 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.
  • P Offline
    P Offline
    philk
    wrote on last edited by
    #1

    I can see a steady increase in memory for images loaded via my own QQuickImageProvider for gridview items. At what point are those images deleted by Qt (Quick)?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chrisadams
      wrote on last edited by
      #2

      Pixmaps are cached in the QQuickPixmapStore. See https://qt.gitorious.org/qt/qtdeclarative/blobs/stable/src/quick/util/qquickpixmapcache.cpp for more details. You can manually purge the cache by calling QQuickWindow::releaseResources().

      Currently, the cache_limit (size of cached pixmaps in the cache) is hardcoded into qquickpixmapcache.cpp. It probably would be useful if this was exposed via a function like QQuickWindow::setResourceCacheLimits(enum WhichResource, int limit) or something. Feel free to file a bug report about that, I guess.

      Cheers,
      Chris.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        philk
        wrote on last edited by
        #3

        Thanks Chris for your answer. However, I do not use Pixmaps, but QImage, as I wrote. What's the difference between PixMap and QImage anyway? Which uses less memory and is more efficient to render?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chrisadams
          wrote on last edited by
          #4

          It's a cache of QQuickPixmap rather than QPixmap. I should have been clearer. Probably best to read the code I linked at gitorious. To create a texture from a QPixmap, it is first converted to a QImage. The rest of the code is basically identical, and it's cached the same way (what is cached is QQuickPixmapData which consists of a texture factory for the image data). In short, two requests for the same QQuickPixmap (ie, see QQuickImage for an example) won't need to go through the provider->requestImage() or provider->requestPixmap() codepath; instead, the data will be returned directly from the cache.

          Performance should be mostly identical, I guess. Benchmark it to find out for yourself though, as I may be wrong about that. Certainly pixmap.toImage() must have some overhead.

          What is eventually rendered is a texture, not a pixmap or an image, of course.

          Cheers,
          Chris.

          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