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. QQuickImageProvider - unload Images / free memory
Forum Updated to NodeBB v4.3 + New Features

QQuickImageProvider - unload Images / free memory

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 355 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.
  • SeDiS Offline
    SeDiS Offline
    SeDi
    wrote on last edited by
    #1

    Hi,
    who owns an image provided by QQuickImageProvider? Does it belong to the displaying QML element or to C++/the provider? Does that depend on the use of the QQIP cache?

    How can I make sure that only a small number of pictures is being held in memory?

    I have not found anything like a "removeImage()" method.

    I have thought about using a QQuickImageProvider to provide hundreds of photos from C++ to QML.
    I only need about 5-15 of them at a time
    After their use they have to be deleted from memory, because the user may browse through loads of them and I don't want that excessive use of memory.

    I use lazy loading on the QML side. Each photo will be displayed on one SwipeView page. Those pages are being dynamically created and removed in QML, so that the number of pages to be viewed over time is unlimited, while the number of existing pages at a given time remains more or less constant in the SwipeView.

    jeremy_kJ 1 Reply Last reply
    0
    • SeDiS SeDi

      Hi,
      who owns an image provided by QQuickImageProvider? Does it belong to the displaying QML element or to C++/the provider? Does that depend on the use of the QQIP cache?

      How can I make sure that only a small number of pictures is being held in memory?

      I have not found anything like a "removeImage()" method.

      I have thought about using a QQuickImageProvider to provide hundreds of photos from C++ to QML.
      I only need about 5-15 of them at a time
      After their use they have to be deleted from memory, because the user may browse through loads of them and I don't want that excessive use of memory.

      I use lazy loading on the QML side. Each photo will be displayed on one SwipeView page. Those pages are being dynamically created and removed in QML, so that the number of pages to be viewed over time is unlimited, while the number of existing pages at a given time remains more or less constant in the SwipeView.

      jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      @SeDi said in QQuickImageProvider - unload Images / free memory:

      Hi,
      who owns an image provided by QQuickImageProvider? Does it belong to the displaying QML element or to C++/the provider? Does that depend on the use of the QQIP cache?

      The function signature indicating an object rather than a reference or pointer makes it clear that the provider does not own the image returned to the QML engine.

      https://doc.qt.io/qt-6/qquickimageprovider.html#requestImage

      QImage QQuickImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
      

      How can I make sure that only a small number of pictures is being held in memory?

      I have not found anything like a "removeImage()" method.

      https://doc.qt.io/qt-6/qquickimageprovider.html#image-caching

      Images returned by a QQuickImageProvider are automatically cached, similar to any image loaded by the QML engine. When an image with a "image://" prefix is loaded from cache, requestImage() and requestPixmap() will not be called for the relevant image provider. If an image should always be fetched from the image provider, and should not be cached at all, set the cache property to false for the relevant Image or BorderImage object.

      So the decision is made by the consumer of the image, rather than the provider or engine. The provider can of course maintain its own private cache.

      I have thought about using a QQuickImageProvider to provide hundreds of photos from C++ to QML.
      I only need about 5-15 of them at a time
      After their use they have to be deleted from memory, because the user may browse through loads of them and I don't want that excessive use of memory.

      Does implementing the application using the framework-provided image providers result in acceptable memory usage? I would expect roughly similar consumption.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      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